Undisable some elements inside a disabled field

Is there a way (such as an element attribute) to "unisable" a specific element when the parent is fieldsetdisabled? If not, then what is good practice to disable the entire form with specific exceptions?

<fieldset disabled>
  Name: <input type="text"><br>

  <!-- Email shouldn't be disabled -->
  Email: <input type="text"><br>

  <!-- more fields ... -->
</fieldset>
+4
source share
1 answer

Dear, use this example to achieve your goal.

 $(document).ready(function () {
            $('#form :input').prop('disabled', true);
            $("#btn1").prop('disabled', false);
        })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<fieldset id="form">

  <legend>Personalia:</legend>
  Name: <input type="text" /><br />
  Email: <input type="text" /><br />
  Date of birth: <input type="text" />

  <input id="btn1" type="button" value="See More (Enable this!!) " onclick="ButtonClicked1()" />
  Somethingelse: <input type="text" />
 <input type="button" value="View Details " onclick="ButtonClicked2()"/> 

  </fieldset>
Run code
0
source

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


All Articles