HTML中让表单input等文本框为只读不可编辑的方法
2017-12-04 15:46
465 查看
方法1: onfocus=this.blur() 当鼠标放不上就离开焦点
[html] view
plain copy
<input type="text" name="input1" value="中国" onfocus=this.blur()>
方法2:readonly
[html] view
plain copy
<input type="text" name="input1" value="中国" readonly>
<input type="text" name="input1" value="中国" readonly="true">
[html] view
plain copy
方法3: disabled
[html] view
plain copy
<input type="text" name="input1" value="中国" disabled="true">
完整的例子:
[html] view
plain copy
<input name="ly_qq" type="text" tabindex="2" onMouseOver="this.className='input_1'" onMouseOut="this.className='input_2'" value="123456789" disabled="true" readOnly="true" />
disabled="true" 此果文字会变成灰色,不可编辑。
readOnly="true" 文字不会变色,也是不可编辑的
css屏蔽输入:<input
style="ime-mode: disabled">
有两种方法:
第一:disabled="disabled"这样定义之后被禁用的 input 元素既不可用,也不可点击。
第二:readonly="readonly" 只读字段是不能修改的。不过,用户仍然可以使用 tab 键切换到该字段,还可以选中或拷贝其文本;
[html] view
plain copy
<input type="text" name="input1" value="中国" onfocus=this.blur()>
方法2:readonly
[html] view
plain copy
<input type="text" name="input1" value="中国" readonly>
<input type="text" name="input1" value="中国" readonly="true">
[html] view
plain copy
方法3: disabled
[html] view
plain copy
<input type="text" name="input1" value="中国" disabled="true">
完整的例子:
[html] view
plain copy
<input name="ly_qq" type="text" tabindex="2" onMouseOver="this.className='input_1'" onMouseOut="this.className='input_2'" value="123456789" disabled="true" readOnly="true" />
disabled="true" 此果文字会变成灰色,不可编辑。
readOnly="true" 文字不会变色,也是不可编辑的
css屏蔽输入:<input
style="ime-mode: disabled">
有两种方法:
第一:disabled="disabled"这样定义之后被禁用的 input 元素既不可用,也不可点击。
第二:readonly="readonly" 只读字段是不能修改的。不过,用户仍然可以使用 tab 键切换到该字段,还可以选中或拷贝其文本;
相关文章推荐
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- js中对arry数组的各种操作小结 瀑布流AJAX无刷新加载数据列表--当页面滚动到Id时再继续加载数据 web前端url传递值 js加密解密 HTML中让表单input等文本框为只读不可编辑的方法 js监听用户的键盘敲击事件,兼容各大主流浏览器 HTML特殊字符
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法
- HTML中让表单input等文本框为只读不可编辑的方法汇总
- HTML中让表单input等文本框为只读不可编辑但可以获取value值的方法;让文本域前面的内容显示在左上角,居中
- 修改placeholder的颜色 、HTML中让表单input等文本框为只读不可编辑的方法
- HTML:让表单 文本框 只读,不可编辑的方法
- Html中让表单、文本框、文本域、按钮等不可编辑,只读的方法
- HTML中让表单input等文本框不可编辑的方法