系统有个栏位,作为参数设置,限制用户只能输入大于0的正整数:
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<input type="text" name="non" ng-model="non" onpaste="return false;" onkeyup="if ( this.value.length == 1 ) { this.value = this.value.replace(/[^1-9]/g, '') } else { this.value = this.value.replace(/\D/g, '') }" onafterpaste="if ( this.value.length == 1) { this.value = this.value.replace(/[^1-9]/g, '0') } else { this.value = this.value.replace(/\D/g, '') }" />
上面有一个onpaste属性,即是说,此文本框不接受粘贴数据。