9

Is there a way (like an attribute on an element) to 'undisable' a specific element when the parent fieldset is disabled? Preferable without any JavaScript. If not, what is a good practice to disable an 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>
Thijs
  • 3,015
  • 4
  • 29
  • 54
  • I think it's not possible. `
    ` is used to disable all field, unless condition given to it. For ex, if you want to remove disable of name text box, then don't give disable in fieldset and using `
    – Nana Partykar Feb 04 '16 at 09:43

2 Answers2

1

Put your input inside the <legend> element:

<fieldset disabled>
  <legend>
    <label>Email: <input></label>
  </legend>

  <label>Name: <input></label>
  <!-- more fields ... -->
</fieldset>
Rúnar Berg
  • 4,229
  • 1
  • 22
  • 38
0

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>
  • 2
    Thank you for your answer but I would like to do it without JavaScript. – Thijs Sep 07 '16 at 07:19
  • This is a legitimate answer! Though the OP was looking for good practice, he didn't specify that it need not be javascript. How much this hack is good practice is measure in degree not in absolute. – Sinker Oct 16 '17 at 05:39
  • 1
    Here is an answer for ` – Rúnar Berg Mar 14 '19 at 05:49