I have 3 input fields that ask for the number of people, and of them how many are adults and how many are children. I am trying to use jQuery validate plugin to add a custom
As suggested in comments this is not a good practice. Nonetheless, if you still want to do it:
$("#form2").validate({
errorElement: "span",
rules: {
attendees: {
equal: $("#form2 #adults").val() + $("#form2 #children").val();
},
adults: {
required: true,
digits: true
},
children: {
required: true,
digits: true
}
},
messages: {
attendees: "Enter the number of persons (including yourself)",
adults: "Enter number of adults",
children: "Enter number of childern"
}
});