jquery validation plugin - strange required behaviour
Hi Team, I have a form with several optional input fields.
I would like them to be validated IF they have a value. In my rules I define code as follows:
row: {
required: {
depends: function(element) {
if ($("#row").val() != '') {
return true;
} else {
return false;
}
}
},
pattern: /^[0-9]*$/
},
This appears to be fine whilst I enter data, but when the form is submitted all the input boxes have a green tick appended even if the field has no value. Should I expect this or have I missed something obvious or even subte in my depends conditions?
Thx Paul