HTML中让表单中输入项不可修改方法总解
2013-03-05 15:32
267 查看
如使<input type = "text" name = "country" id = "country" value = "中国">的内容,“中国“两个字不可修改,实现的方法总解如下:
(1)onfocuse = this.blur()
代码复制如下:
<input type = "text" name = "country" id = "country" value = "中国" onfocus = this.blur()>
分析:onfocuse = this.blur()
onfocuse 是聚焦的意思,当你把光标放在文本框上输入的时候,就是聚焦,但是添加了"this.blur()",blur的作用是去除聚焦,也就是你不能把光标放在文本框上,换句话说你不能输入文本框了。
整个代码就构成了不能输入任何文本的文本框。
适用范围:input单文本/多文本
(2)添加readonly的属性
代码复制如下:
<input type = "text" name = "country" id = "country" value ="中国" readonly>
或者:<input type = "text" name = "country" id = "country" value ="中国" readonly = “true”>
或者:<input type = "text" name = "country" id = "country" value ="中国" readonly = "readonly”>
适用范围:input单文本/多文本
(3)添加diabled 的属性
代码复制如下:
<input type = "text" name = "country" id= "country" value = "中国" diabled>
或者:<input type = "text" name = "country" id= "country" value = "中国" diabled =“diabled”>
或者:<input type = "text" name = "country" id= "country" value = "中国" diabled = "true">
适用范围:input单文本/多文本 select下拉列表
(1)onfocuse = this.blur()
代码复制如下:
<input type = "text" name = "country" id = "country" value = "中国" onfocus = this.blur()>
分析:onfocuse = this.blur()
onfocuse 是聚焦的意思,当你把光标放在文本框上输入的时候,就是聚焦,但是添加了"this.blur()",blur的作用是去除聚焦,也就是你不能把光标放在文本框上,换句话说你不能输入文本框了。
整个代码就构成了不能输入任何文本的文本框。
适用范围:input单文本/多文本
(2)添加readonly的属性
代码复制如下:
<input type = "text" name = "country" id = "country" value ="中国" readonly>
或者:<input type = "text" name = "country" id = "country" value ="中国" readonly = “true”>
或者:<input type = "text" name = "country" id = "country" value ="中国" readonly = "readonly”>
适用范围:input单文本/多文本
(3)添加diabled 的属性
代码复制如下:
<input type = "text" name = "country" id= "country" value = "中国" diabled>
或者:<input type = "text" name = "country" id= "country" value = "中国" diabled =“diabled”>
或者:<input type = "text" name = "country" id= "country" value = "中国" diabled = "true">
适用范围:input单文本/多文本 select下拉列表
相关文章推荐
- 修改placeholder的颜色 、HTML中让表单input等文本框为只读不可编辑的方法
- html文本框不可编辑,禁止用户修改的几种方法
- js中对arry数组的各种操作小结 瀑布流AJAX无刷新加载数据列表--当页面滚动到Id时再继续加载数据 web前端url传递值 js加密解密 HTML中让表单input等文本框为只读不可编辑的方法 js监听用户的键盘敲击事件,兼容各大主流浏览器 HTML特殊字符
- HTML中让表单input等文本框不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- Html中让表单、文本框、文本域、按钮等不可编辑,只读的方法
- 几种设置表单元素中文本输入框不可编辑的方法
- 几种设置表单元素中文本输入框不可编辑的方法总结
- 几种设置表单元素中文本输入框不可编辑的方法
- 几种设置表单元素中文本输入框不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- 几种设置表单元素中文本输入框不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- 几种设置表单元素中文本输入框不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑但可以获取value值的方法;让文本域前面的内容显示在左上角,居中
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML:让表单 文本框 只读,不可编辑的方法
- AngularJS进阶(三)HTML:让表单、文本框只读,不可编辑的方法
- HTML:让表单 文本框 只读,不可编辑的方法