With a simple MVC4 application I have a simple view with a simple form with some fields that have some simple validations (required, max/min, length, etc.). I have both ClientValidationEnabled and UnobtrusiveJavaSciptEnabled set to true.
What I want to do is, at any point in time, in javascript, ask if any one particular input field in my form will pass validation with the contents currently in the field.
I realize I can call $("#MyForm").valid()
and know if the whole form itself passes validation. What I want to do is ask this question for any one particular field.
You practically answered your own question :)
Use .valid()
.
http://docs.jquery.com/Plugins/Validation/valid
You can call .valid()
on elements directly.
$("#myElement").valid();
You can also trigger validation this way. http://docs.jquery.com/Plugins/Validation/Validator/element
$("#myForm").validate().element("#myElement");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With