I am adding select fields using javascript & its working fine I want to add valiadation
<select>
<option>8mm</option>
<option>10mm</option>
<option>12mm</option>
</select>
<select>
<option>8mm</option>
<option>10mm</option>
<option>12mm</option>
</select>
<select>
<option>8mm</option>
<option>10mm</option>
<option>12mm</option>
</select>
If user select 8mm in the first select then 8mm will disable in other two select tag.
Here is the JS Code for adding select field
var x = 1; //Initial field counter is 1
var maxField = 6; //Input fields increment limitation
var addButton = $('.add_button'); //Add button selector
var wrapper = $('.field_wrapper'); //Input field wrapper
var fieldHTML = `<div>
<span class="w-1/2 mr-2">
<label for="basicRate">Basic</label>
<select name="basicRate[]" id="basicRate" onchange="getBasicVal(this);" required>
<option value="8">8mm</option>
<option value="10">10mm</option>
<option value="12">12mm</option>
<option value="16">16mm</option>
<option value="20">20mm</option>
<option value="25">25mm</option>
</select>
</span>
<span class="w-1/2">
<label for="">Quantity (in tons)</label>
<input id="quantity" type="text" name="quantity" placeholder="" required />
</span><a href="javascript:void(0);" class="remove_button" title="Remove">Remove</a>
</div>`;
//New input field html
//Once add button is clicked
$(addButton).click(function(){
//Check maximum number of input fields
if(x < maxField){
x++; //Increment field counter
$(wrapper).append(fieldHTML); //Add field html
}
});
//Once remove button is clicked
$(wrapper).on('click', '.remove_button', function(e){
e.preventDefault();
$(this).parent('div').remove(); //Remove field html
x--; //Decrement field counter
});
Here is the UI
As you see first two drop-down has same value 10mm means user can select same values. Am looking for simple validation if user select some option then he or she wont select the same value in other dropdown.
Thanks in advance
