Sai*_*han 1 html javascript forms jquery
我有一个输入字段表.表格将由没有经验的用户使用,所以我想做最坏的准备.
我创建了一些代码,一旦输入字段发生变化就会突出显示表格行.这里的缺点是在用户点击输入字段之外后触发代码.
我希望实现的目标如下.
他们将使用的浏览器具有完整的html5和css3支持,作为JavaScript引擎,我使用最新版本的jQuery.
PS.如果对此有任何不利之处,请告诉我.
使用该keyup事件,输入的值将在此事件触发时更新,但您可以在用户blur输入元素之前更改该值.
您可以使用正则表达式将输入限制为仅限数字:
//bind to the `keyup` event for all `input` element(s)
$('input').on('keyup', function () {
//replace the value of this input by only the digits in it's value
//note that this method works even if the user pastes a block of text into the input
this.value = this.value.replace(/[^0-9]/gi, '');
});?
Run Code Online (Sandbox Code Playgroud)
这是一个演示:http://jsfiddle.net/bKsTG/1/
| 归档时间: |
|
| 查看次数: |
1174 次 |
| 最近记录: |