I have
$("#myForm").validate({
....
rules: {
phone1: {
required: {
depends: "!#pri_noPhone:checked"
},
number: true,
minlength:3,
}
It doesn't throw an error, but it still tries to validate the phone number.
try something like this:
"#phone1": {
number: true,
minlength:3,
required: function(element){
return ($('#pri_noPhone_wrapper input:checked').val() == 'True');
}
}
The HTML (after looking at this I forgot to add the wrapper HTML)
<span id='pri_noPhone_wrapper'>
Phone:
<input type="checkbox" name="pri_noPhone" value="what ever" />
</span>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With