当前位置:网站首页>Form Validation

Form Validation

2022-06-21 09:14:00 Tie Hanhan plus

  • Limit input Box to enter only pure integer numbers
<input type="text" class="input-number" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" name="password" ng-maxlength="10">
       // onKeyUp="value=value.replace(/[\W]/g,'')" //  Match English and numbers 
  • Limit input Box to enter only two decimal digits ( The highest 10 position )
<input type="number" oninput="value=value.replace(/\D*(\d*)(\.?)(\d{0,2})\d*/,'$1$2$3');if(value.length>11)value=value.slice(0,11)" pattern="[0-9]*\.?[0-9]{0,2}">
       // pattern="[0-9]*\.?[0-9]{0,2}" -- compatible ios Low version 
原网站

版权声明
本文为[Tie Hanhan plus]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221446082068.html