I'm using the jQuery Validation library to validate forms on on my site before submitting them. I'd like to use one validate() function for all my forms which works great with just adding the required attribute to form inputs. But I've run into a snag.
I want to use validation methods from the additional-methods.js library to validate phone numbers and other special inputs. In my validate() function I would just add the following.
$('form').validate({
rules: {
user_phone: {
phoneUS: true,
},
},
});
But that only works on inputs with the name='user_phone'. I have forms with more than one phone input. Is there a way to use the phoneUS validation method on all inputs with type='tel'?
Thanks in advance to anyone who offers any insight on this.
Edit
I'm looking for something like this...
$.validator.setDefaults({
rules: {
'type=tel': {
phoneUS: true,
},
},
});