基于jquery的设置页面文本框 只能输入数字的实现代码
代码如下: 代码如下: $(“#money”).bind(“propertychange”,function() { if(“”!=this.value){ var str = this.value.replace(/(^\s*)|(\s*$)/g, “”); if(this.value != str ) this.value = str; } if( isNaN(Number(this.value))) this.value = this.value.replace(/[\D]/,”); }); 这里使用了JQuery绑定到id为money的文本框的onpropertychange事件上
下载地址
用户评论