Home > Article > Web Front-end > How to implement HTML text box that can only be read but cannot be modified
This article introduces to you through example code how to implement HTML text boxes that are read-only and cannot modify the content. Friends who need it can refer to it
No more nonsense, I will directly post the code for you. The specific code is as follows:
<!--方法1: onfocus=this.blur() 当鼠标放不上就离开焦点 --> <input type="text" name="input1" value="中国" onfocus=this.blur()> <!-- 方法2:readonly 文字不会变色,也是不可编辑的--> <input type="text" name="input1" value="中国" readonly> <input type="text" name="input1" value="中国" readonly="true"> <!-- 方法3: disabled 此时文字会变成灰色,不可编辑。 --> <input type="text" name="input1" value="中国" disabled="true">
The above is the detailed content of How to implement HTML text box that can only be read but cannot be modified. For more information, please follow other related articles on the PHP Chinese website!