What's the difference between disabled=“disabled” and readonly=“readonly” for HTML form input fields?

后端 未结 5 1460
执笔经年
执笔经年 2020-11-22 04:17

I have read a bit on this, but I can\'t seem to find anything solid about how different browsers treat things.

5条回答
  •  不思量自难忘°
    2020-11-22 04:59

    If the value of a disabled textbox needs to be retained when a form is cleared (reset), disabled = "disabled" has to be used, as read-only textbox will not retain the value

    For Example:

    HTML

    Textbox

    
    

    Reset button

    
    

    In the above example, when Clear button is pressed, disabled text value will be retained in the form. Value will not be retained in the case of input type = "text" readonly="readonly"

提交回复
热议问题