How to make an entire HTML form “readonly”?

Spread the love

Sometimes, we want to make an entire HTML form "readonly".

In this article, we’ll look at how to make an entire HTML form "readonly".

How to make an entire HTML form "readonly"?

To make an entire HTML form "readonly", we wrap the fields with a fieldset element and make the fieldset disabled.

For instance, we write

<form>
  <fieldset disabled="disabled">
    <input type="text" name="something" placeholder="enter some text" />
    <select>
      <option value="0" disabled="disabled" selected="selected">
        select somethihng
      </option>
      <option value="1">woot</option>
      <option value="2">is</option>
      <option value="3">this</option>
    </select>
  </fieldset>
</form>

to wrap the select element within a fieldset.

Then we make the fieldset disabled to disable the select drop down.

Conclusion

To make an entire HTML form "readonly", we wrap the fields with a fieldset element and make the fieldset disabled.

Leave a Reply

Your email address will not be published. Required fields are marked *