Hey! How are you :)
I'm triying to make it works, but i can't find a solution. I read all the closed issues, but any example works for me. This is the problem: I've got 3 text input fields, if at least one is complete, the form should be validated.
And the validator:
$("#frm_personales").validator({custom: {personales: function($el) {if($('#email').val() === '' || $('#telcel').val() === '' || $('#whatsapp').val() === ''){return "At least one field must be completed.";};}}})
It never validates... just always submits the form... otherwise, if i make them all required, the rule is usless.
Any comment can be usefull. Tnks! :)
I think you're probably better off just toggling the required attribute on your inputs as necessary instead of using a custom validator. Here's an example of what I think you want.
Hey! How are you :) I'm triying to make it works, but i can't find a solution. I read all the closed issues, but any example works for me. This is the problem: I've got 3 text input fields, if at least one is complete, the form should be validated.
<input type="email" pattern="^[-\w.]+@{1}[-a-z0-9]+[.]{1}[a-z]{2,5}$" class="form-control" data-personales="email" id="email" name="email">;
<input type="text" class="form-control" data-personales="telcel" id="telcel" name="telcel">;
<input type="text" class="form-control" data-personales="whatsapp" id="whatsapp" name="whatsapp">
And the validator:
$("#frm_personales").validator({
custom: {
personales: function($el) {
if($('#email').val() === '' || $('#telcel').val() === '' || $('#whatsapp').val() === ''){
return "At least one field must be completed.";
};
}}})
It never validates... just always submits the form... otherwise, if i make them all required, the rule is usless. Any comment can be usefull. Tnks! :)