I’m using the unobtrusive jQuery client side validation in MVC 3. I have a [Required] attribute on my model property. When I clear out the textbox on my form, it doesn’t show the validation error. However if I manually call document.forms['myform'].valid(), and then clear out the textbox, it immediately shows the validation error.
It looks like the validation isn’t hooking into the keyUp event until after valid() is manually called.
Any ideas on how to make this work without having to call valid() manually?
Validation triggers when you try to submit the form. Once you have clicked on the submit button it will work on blur. If you want to eagerly perform validation on blur without the need of submitting once you could use the following script: