About readonly and disabled attributes of html form elements

    The readonly attribute specifies that the input field is read-only. Read-only fields cannot be modified. However, the user can still tab to the field and select or copy its text. readonly is only valid for text, password and textarea. Setting it on form elements such as select, radio, checkbox, etc. will have no effect, the user can still change the value of the form element selected.

 

    readonly is only used to prevent the user from modifying the value of the form element, and does not prevent the submission of the form element when the form is submitted. The disabled attribute indicates that the form element is disabled. A disabled form element is neither usable nor clickable, cannot receive focus, and cannot select its text content. This attribute is valid for form elements such as text, password, textarea, select, radio, checkbox, hidden, and option. The disabled attribute not only prevents the user from manipulating the element, but also prevents the form element from submitting when the form is submitted. E.g:

 

<input name="test" type="text" disabled="disabled" value="hello"/>

     Since the form element test has the disabled attribute, when the form is submitted, the form element will not be submitted together with the form, so the request we receive from the background server will not contain the parameter named test.

 

 

Attribute name is read-only for element can get focus follow form submit
readonly text, password and textarea elements only Yes Yes Yes
disabled 所有<input>、 <button>、 <select>、
<optgroup>、 <option>、 <textarea>标签
Yes no no

 

 

 

.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326183853&siteId=291194637