I have 2 fields
<input type="text" name="num_gals" placeholder="Num of Gallons">
<input type="checkbox" value="TRUE" name="full_tank">Full Tank?
I am using jquery-validation to enforce the following rule. Either the input field "num_gals" should have a non-zero value or the "full_tank" checkbox should be checked.
I tried the following but it doesn't seem to work.
rules:
{
num_gals:
{
required: function()
{
if ($('.full_tank').val(':checked')) {
return false;
} else {
return true;
}
}
},
full_tank:
{
required: function()
{
if ($('.num_gals').val() == '') {
return true;
} else {
return false;
}
}
}
},
messages:
{
num_gals:
{
required: 'Provide Num Gals or Check Full Tank'
},
full_tank:
{
required: 'Provide Num Gals or Check Full Tank'
}
}
Would appreciate the help!