here is my code:
groups: {
phone: "phone1-phone2-phone3"
digits: true
},
errorPlacement: function(error, element) {
if (element.attr("name") == "phone1"
|| element.attr("name") == "phone2" || element.attr("name") == "phone3")
error.insertAfter开发者_运维问答("#telephone");
else
error.insertAfter(element);
},
debug:true
here is my form input text:
<p><label for="name"><span class="red">*</span>Phone: </label> <input type="text" name="phone1" id="phone1" size="3" tabindex="12" />-<input type="text" name="phone2" id="phone2" size="3" tabindex="12" />-<input type="text" name="phone3" id="telephone" size="4" tabindex="12" /></p>
the above didnt validate? any ideas is much appreciated!
the input ids in groups must be delimited by spaces not -
. Here is the code
$("#form").validate({
groups: {
phone: "phone1 phone2 telephone"
},
rules: {
phone1 : "digits",
telephone : "digits",
phone2 : "digits"
},
onsubmit: false,
errorPlacement: function(error, element) {
if (element.attr("name") == "phone1"
|| element.attr("name") == "phone2" || element.attr("name") == "phone3")
error.insertAfter("#telephone");
else
error.insertAfter(element);
},
debug:true
});
The rules need to be specified under the rules option
精彩评论