How to enable all inputs when a selection is selected?

I have (over 10) inputs in my HTML form. In the initial state, all of these inputs are disabled by default. There is also a select element that changes the property of disabled exact inputs when selecting based on the selected value. In other words, the select element contains parameters that indicate which input to include. Now I want to enable accurate input based on the selected option. How can I do that?

+4
source share
2 answers

Add a class to the "exclusive", for example. special :

 <input ... class='special' /> 

Then enable everything except this with:

 $('input').not('.special').removeAttr('disabled'); 
+4
source
 $('select').change(function() { if ($(this).val() === 'whatever') { $(':input:not(.whatever)').removeAttr('disabled'); } }); 
+2
source

Source: https://habr.com/ru/post/1332187/


All Articles