HTML input readonly attribute
Examples
With a read-only HTML form input fields:
<form
action="demo_form.html">
Country: <input type="text" name="country" value="Norway" readonly><br>
<input type="submit" value="提交">
</form>
Country: <input type="text" name="country" value="Norway" readonly><br>
<input type="submit" value="提交">
</form>
try it"
Browser Support
All major browsers support the readonly attribute.
Definition and Usage
readonly attribute is a Boolean attribute.
readonly attribute specifies the input field is read-only.
Read-only field can not be modified. However, users can still use the tab key to switch to the field, you can also select or copy its text.
readonly property can prevent users modify the value, up until certain conditions are met (such as a check box is selected). Then, you need JavaScript eliminate readonly value, will switch to the input field editable.
Differences between HTML 4.01 and HTML5
no.
Differences between HTML and XHTML
In XHTML, prohibit attribute minimization, readonly attribute must be defined as <input readonly = "readonly" />.
grammar
<input readonly>
HTML <input> tag