LA_
LA_

Reputation: 20409

How to fix the case with jQuery Validate - only one field is validated?

I have 2 fields in my (simplified) form. And I use jQuery Validate plugin to validate both of them, but only one field is validated - see live example.

What can be wrong here? How to validate both fields?

(there is similar question, but there is no solution)

Upvotes: 0

Views: 218

Answers (2)

vertti
vertti

Reputation: 7879

Your errorPlacement code is broken. If you remove that, you can see that both fields are validated correctly. You only have one <span> in your html so .find("span")); finds that and reports both errors in the same element..

Upvotes: 1

user719958
user719958

Reputation:

Validation is in fact being performed for both fields - you're just not getting an error message. If you do an inspect element (using Chromium, or Firefox with Firebug), you'll see the input tag will have a class error.

You're missing the <span></span> at the end of the div surrounding the last_name input field. Add that empty span, and you'll see the error message come up.

Upvotes: 1

Related Questions