正则表达式格式验证

呃,以后再添加。。。发现要用到的情况实在是多

1、纯数字

2、判断非数,主要是用来验证金额。

<input type="text" onafterpaste="this.value=this.value.replace(/\D/g,'')" onkeyup="this.value=this.value.replace(/\D/g,'')"  />
<input type="text" onafterpaste="if (isNaN(this.value)) {alert('非法输入');this.value = '';}"  onkeyup="if (isNaN(this.value)) {alert('非法输入');this.value = '';}"  />


猜你喜欢

转载自blog.csdn.net/jingjingwin5/article/details/12096807