I have a set of four select drop down's(bootstrap selectpicker
) with same values one to ten with different ids and names ex.[id="select1",id="select2"
].
How can I validate this dropdowns, so user can't select same value. Ex, if user has choosen 1 in first dropdown so i don't want allow him to choose 1 in rest of the dropdowns.
$("select").change(function() { var value = $(this).val();
//alert(value); $("select").not(this).find("option[value ="+value+"]").attr('disabled',true).selectpicker('refresh'); });
I tried above code but it is not working.
Try removing the option:
$("select").click(function() {
var value = $(this).val();
$("select").not(this).find("option[value ="+value+"]").remove(); //.prop('disabled', true);
$("select").not(this).selectpicker('refresh');
});