0

I'm having an (admittedly minor) issue using jQuery validation. I'm trying to validate a form to submit addresses. Within this form, there's a field group containing the City, State, and Zip fields.

It seems that because the zip code field is the last in the markup, its error message always 'trumps' the city error message. So if both the city and zip code are empty or otherwise invalid, the city field's error message won't display, and the zip code message will.

Does jQuery validation have a solution to this problem? Or am I going to have to fight against the framework to accomplish my goal?

Thanks!

4
  • Isn't the common implementation for jQuery Validate to annotate the individual fields? Commented Apr 29, 2015 at 18:50
  • 1
    Show us your code. The demos here jqueryvalidation.org/files/demo show multiple error messages working just fine. Commented Apr 29, 2015 at 18:50
  • I can see how the error container demo would exhibit this behavior, and your options don't look good, maybe with some extra data in your markup like data-error-priority=# you could work out a way to reorder them Commented Apr 29, 2015 at 18:53
  • @ekuusela : Unfortunately I can't show you the code, as it's likely a violation of privacy agreements. Sorry, I can see how that makes it tough to help! Anyway, this link has similar code: stackoverflow.com/questions/1289086/… I'm using a 'groups' object, similar to this one from the link: groups: { DateofBirth: "DayOfBirth MonthOfBirth YearOfBirth" } My object holds the three address fields, which share one div to report error messages. My question is how to control which error message is displayed in the shared div. Commented Apr 29, 2015 at 19:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.