HTML:让表单、文本框只读,不可编辑的方法
2024-10-19 12:41:14
有时候,我们希望表单中的文本框是只读的,让用户不能修改其中的信息,如使<input type="text" name="input1" value="中国"> 的内容,"中国"两个字不可以修改。实现的方式归纳一下,有如下几种。
方法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>
最新文章
- LeetCode之461. Hamming Distance
- iOS App更改显示的项目名
- linux centos service 参数详解
- BookRent借阅管理
- OS开发拓展篇—应用之间的跳转和数据传
- ubuntu配置服务器环境
- shell脚本-获取时间
- 关于mysql 连接数
- oracle——分析函数——排序值分析函数
- VC6.0的工程设置解读Project--Settings
- nginx+lua安装配置
- C++ Primer 5 CH6 函数
- Java 原始数据类型
- SDP(13): Scala.Future - far from completion,绝不能用来做甩手掌柜
- Qzone React Native改造
- C#中添加log4net(日志文件)
- JS自学笔记05
- Windows 8创新之路——样章分享
- 跟我一起学习ASP.NET 4.5 MVC4.0(六)
- 二分查找(等于x,小于x,小于等于x,大于x,大于等于x )