while I was working with validation in MVC, and I wrote a custom attribute to validate a property.Initially the client side validation was not working since attribute was not registered.When i clicked on the save
button after contacting the server it was showing the error message.So can anyone tell how this server side validation took place instead of client side validation ?
attribute usage ->
[PhoneNumberHasPlus(ErrorMessage="Invalid number")]
public string PhoneNumber {get;set;}
attribute ->
public class PhoneNumberHasPlusAttribute : RegularExpressionAttribute
{
public PhoneNumberHasPlusAttribute() :
base(@"^[+][0-9' '\.\-\(\)]{10,20}$") { }
public override string FormatErrorMessage(string name)
{
if (String.IsNullOrEmpty(ErrorMessage))
ErrorMessage = "PhoneNumberWithPlus";
return ErrorMessage;
}
}