HTML中让表单中输入项不可修改方法总解
来源:互联网 发布:c语言常用标准库函数 编辑:程序博客网 时间:2024/06/04 01:37
如使<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下拉列表
- HTML中让表单中输入项不可修改方法总解
- 修改placeholder的颜色 、HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法汇总
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框不可编辑的方法
- Html中让表单、文本框、文本域、按钮等不可编辑,只读的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML:让表单 文本框 只读,不可编辑的方法
- HTML中让input text 不可编辑
- AngularJS进阶(三)HTML:让表单、文本框只读,不可编辑的方法
- js 中判断表单输入方法
- html中输入空格的简单方法
- 如何在PHP中修改html表单中的checkbox值?
- 让表单中的文本区域只读,不可编辑的方法
- CvArr、Mat、CvMat、IplImage、BYTE转换(总结而来)
- Python日期操作date,计算到特定日期的时间。
- asp之字符串函数示例
- 数据库 游标 cursor
- .net 防注入
- HTML中让表单中输入项不可修改方法总解
- Cisco AnyConnect: The VPN client driver has encountered an error
- C#时间函数
- C#分割字符串的几种方法
- MFC 图形编程基础——映射模式和坐标变换
- 树结构性质简介
- JavaScript:ListView示例
- 在线代码转换工具
- ASP.NET发邮件