0

I'm using the jquery validate plugin to validate a form where quite a lot of fields are required. For clarity's sake, I'd like to use the error message container to display error messages, however in that case I'll only see the same generic (or customized) error message for each field.

I'd like at least to be able to add the name of the field in front of each error message in order to make the error messages easier to grasp. Here's an example of what I'd like to achieve:

There are errors in your form:

 - Type of fruit: required
 - Quantity: required
 - Category: required

Instead of simply getting:

There are errors in your form:

 - required
 - required
 - required

I've been searching through the plugin's doc and the internet in general for a while now but couldn't find any indication on how to achieve this in an easy and straightforward manner.

Does anybody know if this can be done, and how?

1 Answer 1

2

I think it's possible to do this:

class="{required:true, messages:{required:'Type of fruit: required'}}"

see an example here - http://jsfiddle.net/eJ4e3/

Sign up to request clarification or add additional context in comments.

1 Comment

@svillamajor Do you know whether it is possible to combine this validate-specific class object with css classes? I saw an example where it was done that way, but the example had exclusively validate classes and no others.

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.