HTML form :: difference between disabled and readonly element

I was working with HTML forms. In the forms I used readonly and disabled input elements. What is the deference between these two attributes of input element?

Say for I have an input element in HTML form.

If we set the attribute readonly="readonly" then the input element is not editable. This attribute allows the user to highlight and copy the text inside the input field, but not change the value.

This attribute is only used if the type attribute of the input element is set to “text” or “password”.

I have another text field like bellow.

If we set the attribute disabled="disabled", the input element is disabled, un-editable and un-selectable. This attribute not allow the users to highlight and copy the text inside the input field. Another thing happen here, the data within the input element will not be submitted to the action page.

Join the Conversation


  1. I agree with Mehedi. Sometimes we search errors in complex things overlooking this type of mistakes. I remember once I faced an issue with disabled field. The data was not coming to my script. After examining my PHP script I found the issue with my HTML disabled field. 😀

  2. I also experienced some difficulties regarding `readonly` and `disabled`. I had to spend a long span of time to find out why my disabled field is not submitting value to action page then realized the thing.

  3. Hi,

    hope this fits this pages intentions.

    I have a form that after submitting sets the fiels to readonly. Problem is that the field are selectable on at the time, but not all together. That’s a problem, because users can’t copy/paste values into a spreadsheet program, like Excel.

    Any suggestions?

    Regards, Martin.

  4. Hi,

    turns out you can’t copy paste like my clients want. I’ll have to put the values direcly in a table cell.

    Work work …

  5. Hi,

    Nice explanation… But i disagree with selecting part and copy paste. whether it is readonly or disabled. we can still highlight/select and copy paste.

    Goutham Ganesh V

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.