jquery validation message
i have 3 form input text for phone number. currently i am validating each input text for a digit.
i have an input message for each individual input text. instead of doing this:
phone1: {
required: true,
maxlength: 3,
digits: true
},
phone2: {
required: true,
maxlength: 3,
digits: true
},
phone3: {
required: true,
maxlength: 4,
digits: true
}
phone1:"enter value!.",
phone2:"enter value!.",
phone3:"enter value!."
i will like to only show one single message for all three fields. right now, i have 3 messages displaying on the screen. is there a way to only show just one until the user completes all required fields.
phone1,phon开发者_运维技巧e2,phone3:
You probably want to use groups along with a custom errorPlacement function.
see here: http://docs.jquery.com/Plugins/Validation/validate#toptions under the heading "groups"
You may want to set the onfocusout
to false and onsubmit
to true so that all validations are done at the time of submit.
If you are talking about having one single message irrespective of which one fails. You may setup a validation rule that validates all of them but marks just one of the fields to be invalid (e.g. Phone1).
精彩评论