I have this snippet:
<input type="checkbox" name="sal_cart" id="sal_cart">
<input type="text" name="sal_unit_price" id="sal_unit_price" class="required">
sal_unit_price can be numeric or string, but it's always required (can't be blank).
So far so good.
If sal_cart is checked, then sal_unit_price MUST be numeric (strings are no more allowed)
According to jQuery Validation dependency-expression, I put this:
$('#form1').validate({
rules: {
sal_unit_price: { number: '#sal_cart:checked' },
},
messages: {
sal_unit_price: { number: 'Please fill in a number' },
}
});
but it doesn't work: even if the checkbox is NOT checked, it still says that it requires a number
Please, can you spot what's wrong with this?
Here is a Fiddle: http://jsfiddle.net/cWD8j/