The first day with jQuery validation, but not the first day with jQuery. A very simple question: I have three text inputs: name, phone and email. I want the name (no sweat), as well as the phone or email address, and make sure the login is valid on the phone or email. I 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 validation causes a different, infinitely recursive and browser crash.
There must be some easy way to do this, but I spent about two hours and it eluded me :(
source share