Alwyn Alwyn - 9 months ago 57
Javascript Question

Debugging Unobtrusive Validation (client side)

I am using unobtrusive validation. My form is rather complex and on cursory look there's no "visible" validation error.

However when I call:

$(valForm).valid();


The result is
false
. I need to debug why, if there's a hidden element etc. that is somehow tripping off a rule. Or may be even the rule itself may not be appropriate.

How can I debug the validation? I need a property/method that tells me which element is bad, and also the rules that it sets off.

I have tried looking into
$.validator
also, but could not find anything that seems related to what I'm looking for.

Answer Source

If you use .validate() instead of .valid() it has a property called errorList which contains the offending element and message. The message may be used to track back the rules being broken.