input标签的相关知识

1、input只能输入数字

<input onkeyup="value=value.replace(/[^\d]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />

2、设置input为只读属性并且让input框没有光标

<input type="text" name="b" onfocus="b.blur()" readonly="true" >或<input type="text" readonly="true" onfocus="this.blur()">
3、input的一般属性
隐藏 <input type="hidden">hidder<.br>

 只读 <input type="text" readonly>只读<.br>

 失效 <input type="text" disabled>失效<.br>

enter键让光标移到下一个输入框

<input onkeydown="if(even.keyCode==13)event.keyCode=9">

4、屏蔽输入法

<input type="text" name="url" style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9">

5、有两种方式只读不能编辑但是有区别的

disabled 说明该input无效,及其value不会传递给任何程序,比如asp,php等

readonly 仅仅是无法编辑,不影响其值的传递。

disabled使用 <input type="text" name="username" value="james"disabled>

readonly使用 <input type="text" name="partNumber" value="1500" readonly>

posted @ 2012-12-28 14:47  totoro118  阅读(224)  评论(0)    收藏  举报