您的位置:首页 > 其它

input 输入特殊非法字符自动删除

2016-12-05 09:55 281 查看
js代码
$("#test").keyup(function() {
var reg = $(this).val().match(/\d+\.?\d{0,2}/);
var txt = '';
if (reg != null) {
txt = reg[0];
}
$(this).val(txt);
}).change(function() {
$(this).keypress();
var v = $(this).val();
if (/\.$/.test(v)) {
$(this).val(v.substr(0, v.length - 1));
}
});
});

html 代码

<form:input
id="test"  htmlEscape="false" path="test"  />


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: