系统有个栏位,作为参数设置,限制用户只能输入大于0的正整数:

文本框仅允许输入大于0的正整数

 

<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, '')
                                }" />
Source Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
  • 2021-11-24
  • 2022-12-23
  • 2021-06-22
  • 2021-06-07
  • 2022-01-14
猜你喜欢
  • 2022-12-23
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案