HTML:让表单 文本框 只读,不可编辑的方法

 

有时候,咱们但愿表单中的文本框是只读的,让用户不能修改其中的信息,如使<input type="text" name="input1" value="中国"> 的内容,"中国"两个字不能够修改。实现的方式概括一下,有以下几种。post

方法1: onfocus=this.blur()
<input type="text" name="input1" value="中国" onfocus=this.blur()> this

方法2:readonly
<input type="text" name="input1" value="中国" readonly> input

<input type="text" name="input1" value="中国" readonly="true"> 博客

方法3: disabled
<input type="text" name="input1" value="中国" disabled> it

摘自王小白博客class

相关文章
相关标签/搜索