Quote OP:
"At least one of the two must be completed.
Currently the validation I use jQuery validate, but that does not
fulfill this function, would you have any idea?"
Incorrect... it does have this ability. See documentation: http://jqueryvalidation.org
It's called the require_from_group
method included in the additional-methods.js
file. Usage as follows:
1) Give each item in the group a common class
.
HTML:
<input class="productinfo" name="partnumber">
<input class="productinfo" name="description">
2) Define the rule as follows, where the first parameter is the minimum number required from the group and the second is the class
you created above.
jQuery:
$(document).ready(function(){
$('#myform').validate({
rules: {
partnumber: {
require_from_group: [1,'.productinfo']
},
description: {
require_from_group: [1,'.productinfo']
}
},
groups: {
mygroup: "partnumber description"
}
});
});
Now, at least partnumber
OR description
must be filled out.
3) Optionally, to clean up the duplication of error messages, use the groups
option as follows, which will lump the error messages for the two inputs above into one.
groups: {
mygroup: "partnumber description"
}