jQuery Validation plugin not validating all fields

Just a quick tip/note. I was using the jQuery validation plugin recently and was perplexed as to why it wasn’t validating a field I had set as ‘required’. After a a few minutes I realized it was due to some invalid HTML. I had not set the type of the input and it appears that the plugin matches inputs on type (otherwise it might try and validate things you didn’t expect I imagine. Anyway, if you ever run across an instance where it isn’t validating a field that you¬†explicitly¬†tell it to, check the HTML and make sure the type attribute is set.

Good:

<input type="text" name="firstName" class="text-input" />


Bad:

<input name="firstName" />

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>