I have two multiselect
<select multiple="multiple" name="cselect" id="cselect" class="required" style="width: 240px;">
And the other one
<select multiple="multiple" name="pselect" id="pselect" class="required" style="width:240px;">
I am trying to validate so that atleast one from ech is selected.
$(document).ready(function() {
$('#submit_save').click(function() {
if(smValidator.form()) {
} else {
return false;
}
});
var smValidator = $('#form_config_channel').validate({
rules: {
cselect: {
required: true,
},
pselect : {
required: true,
}
},
messages: {
cselect: {
required: 'Channel Name: Required',
},
pselect: {
required: "Package Name: Required",
}
},
});
});
But it is not working. Can someone please point out where is the mistake?
Here’s your code in jsfiddle with the information you provided. It seems to work fine.
Chances are your form selector is wrong or your HTML is not well-formed–you may have to post the full page if you cannot spot the error.
Also note that you don’t usually need to manually hook up the validation call, jquery.validate does it for you.