I have a select with two values (allow and disallow), and below this select two input disabled to type the password, the idea is that if you select the value allow automatically I enable the input to type the password...
I leave the simple code of the html...
<select class="form-control m-b-10">
<option value="false">No permitir 1</option>
<option value="true">Permitir 2</option>
</select>
<input type="password" name="pass" disabled>
<input type="password" name="pass1" disabled>
I would appreciate the interest.
It can be something like this (you must previously load jQuery):
Check with this, in each change of the select, it validates the value of the option
You can do it by giving an id to your select, in this case I have given it
estado
. Then in jQuery you check if something is selected usingchange()
, and set your input property totrue
orfalse
based on the value of the called variablesino
.To make it work you just have to add
id="estado"
to the end of your select, as the example shows.Note:
Maybe you have to check what happens in each input. For example if you select allow and the input is activated, you write values and then select disallow... I've added a snippet of code to delete what I have written in case the input returns to the deactivated state. By the way I have applied background colors using CSS , just to show an interesting possibility for the input. :)
You can test the code by clicking the blue Run button.
Do not complicate yourself, it is simpler than all that. ENABLE:
TO DISABLE: