I'm attempting to do validation on form fields via MVCs regular expression attributes. But it seems that no matter what regular expression I use, the validation only works on the server side, but not in the browser.
The code I am using for the validation is:
[DisplayName("Email Address")]
[Required]
[RegularExpression(@"^[a-zA-Z0-9\.-]*@[a-zA-Z0-9\.]*\.[a-zA-Z\.]{2,6}$", ErrorMessage = "Valid email required.")]
public string emailAddress { get; set; }
The regular expression will fail validation with "asd"
, "asd@"
but it starts to pass validation at "asd@asd"
when it shouldn't. Pasting the regular expression into http://regexpal.com/ will show that it should only work with full emails.
Screenshots: http://puu.sh/2P05x.png
If it helps, this is being used in a Kendo UI grid edit pop up.