please advise me how one can validate multiple dropdowns in a form, validation should trigger if same value is selected in different dropdowns.
here, if i select same option from both the dropdown it should trigger validation.
(i am using jquery validation engine for form validations)
<select name="user[role_id]">
<option value="">Please select</option>
<option value="1" selected="selected">Administrator</option>
<option value="2">User</option>
<option value="3">Editor</option>
</select>
<select name="user[role_id]">
<option value="">Please select</option>
<option value="1" selected="selected">Administrator</option>
<option value="2">User</option>
<option value="3">Editor</option>
</select>
thanks
Easiest way is to map the selections and look for dupes. There are better algorithms to look for dupes (i.e. exit as soon as you detect a duplicate), but I opted to use shorter code since the cost is very low: http://jsfiddle.net/rkw79/vqENk/