First day with jQuery Validation but not first day with jQuery. Very simple question: I have three text inputs: name, phone, and email. I want to require name (no sweat) and EITHER phone OR email, and make sure the input is valid in EITHER phone OR email. I've tried this with:
$(document).ready(function() {
$("#contactForm").validate({
debug:true,
rules: {
name: {
required: true
},
email: {
email:true,
required: function(element){
!$("#phone").valid();
}
},
phone: {
phoneUS: true,
required: function(element){
!$("#email").valid();
}
}
},
messages: {
name: "Please specify your name",
email: {
required: "Please enter a valid email"
},
phone: "Please enter a 10 digit phone number"
}
});
});
But it fails because each validity check calls the other, recursing infinitely and crashing the browser.
There has to be some easy way to do this, but I've spent close to two hours on it and it escapes me :(