How to implement HTML text box that can only be read but cannot be modified

巴扎黑
Release: 2018-05-15 16:12:56
Original
2648 people have browsed it

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">
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template