Using the optional additional-methods.js
file, there is a method called require_from_group
that does exactly what you request. (You must use at least version 1.11.1 of the plugin in order to avoid a past bug.)
rules: {
mobile:{
require_from_group: [1, '.mygroup']
},
telephone:{
require_from_group: [1, '.mygroup']
}
},
....
The 1
parameter is how many from the group are required. In the HTML markup, the fields in your group must contain a class
matching the class
specified in your second parameter.
<input type="text" class="mygroup" name="mobile" />
<input type="text" class="mygroup" name="telephone" />
Working DEMO: http://jsfiddle.net/NfcxX/
My demo also shows the groups
option which combines the multiple error messages into one.