1. 首页
  2. 大数据
  3. Hadoop
  4. 基于jquery的设置页面文本框 只能输入数字的实现代码

基于jquery的设置页面文本框 只能输入数字的实现代码

上传者: 2020-12-07 01:53:35上传 PDF文件 27.25KB 热度 3次
代码如下: 代码如下: $(“#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事件上
下载地址
用户评论