Need a little help. So got a form, where I\'ve got two fields mobile and telephone. Only one is required. My code below does that, but what I would like is I don\'t want peo
You could keep a variable with the amount of validated items:
validatedItems : 0,
mobile : {
var self = this;
required: function(element) {
if ($("#telephone").val().length > 0) {
self.validatedItems--;
return false;
}
else {
self.validatedItems++;
return true;
}
}
},
telephone: {
var self = this;
required: function(element) {
if ($("#mobile").val().length > 0) {
self.validatedItems--;
return false;
}
else {
self.validatedItems++;
return true;
}
}
},
And then you could check if one or more items are validated when you send the form:
if( validatedItems > 0 ) {
sendForm();
}