I need to validate by id and not input name because my input name is data[name]. I also have a rule to allow one or both fields.
I can add the rules with id but I cannot combine both rules. Is there a way.
<input id="email" type="email" class="form-control contact-method" name="data[email]" placeholder="Email">
<input id="phone" type="text" class="form-control contact-method" name="data[phone]" placeholder="Phone">
Js Code:
$('#requestDemo').validate({ // <- attach '.validate()' to your form
debug: false,
errorElement: "span",
errorClass: "help-block",
rules: {
phoneInput: {
require_from_group: [1, ".contact-method"]
},
emailInput: {
require_from_group: [1, ".contact-method"]
}
},