How to set input read-only in php: 1. Open the corresponding code file; 2. Set input read-only through "".
The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer
php How to set input read-only?
Detailed explanation of the input attribute in PHP (hide read-only restriction)
Hide
<input type ="hidden">
readonly
<input type="text" readonly>
Disabled
<input type="text" disabled>
Restrictions
<input type="text" maxlength="1">
ENTER key moves the cursor to the next input box
<input onkeydown="if(event.keyCode==13)event.keyCode=9">
Shield input method
<input type="text" name="url" style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9">
There are two ways to achieve the read-only effect of input: disabled
and readonly
.
Of course the two effects can only be read but not edited, but they are very different.
Disabled indicates that the input is invalid and its value will not be passed to any program, such as asp, PHP, etc.
Readonly only cannot be edited and does not affect the transfer of its value.
Disabled use:
<INPUT type=”text” name=”username” value=”james” disabled> Readonly使用: <INPUT type=”text” name=”partNumber” value=”1500″ readonly>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to set input read-only in php. For more information, please follow other related articles on the PHP Chinese website!