View Full Version : [CLOSED] MVC Form Email Address Validation

Jan 16, 2015, 8:58 AM
I have a View model property

[Display(Name = "Email")]
public string Email { get; set; }

And in the view

Html.X().TextFieldFor(m => m.Email),

The [EmailAddress] validator is triggered as soon as you start typing in the text filed. It is annoying because you are not done typing in your email address and it is immediately telling you that it is not in a correct format.
Can this be somehow triggered on bur or something?

Jan 16, 2015, 4:04 PM
Hi @registrator,

Validation happens when the Change event fires. By default, the Change event fires also on typing of each character.

You can try to set up your own set of the CheckChangeEvents.

@X.TextFieldFor(m => m.Email).CheckChangeEvents(new string[] { "blur" })

See also

Jan 17, 2015, 11:38 AM
thank you. very useful info. it works.