Simple Example of js method data verification, js verification instance
Example:
// The input tag can only be a positive number <input onkeyup = "this. value = this. value. replace (/[^ 1-9]/g, '')"> // only a positive integer function CheckNum (thisobj) {if (thisobj. value = "0") {} else {var firstNum = thisobj. value. toString (). substring (0, 1); if (thisobj. value. length = 1) {thisobj. value = thisobj. value. replace (/[^ 0-9]/g, '');} else if (thisobj. value. length> 1 & firstNum = "0") {thisobj. value = "0";} else if (thisobj. value. length> 1) {thisobj. value = thisobj. value. replace (/[^ 0-9]/g, '') }}// you can only enter the amount function ClearNoNum (obj) {if (obj. value = "0") {} else {var firstNum = obj. value. toString (). substring (0, 1); if (obj. value. length> 1 & firstNum = "0") {obj. value = "0" ;}}// replace all non-numeric values first, except numbers and. obj. value = obj. value. replace (/[^ \ d.] /g, ""); // The first one must be a number instead of a number. obj. value = obj. value. replace (/^ \. /g, ""); // ensure that only one exists. no. obj. value = obj. value. replace (/\. {2,}/g ,". "); // guarantee. only appears once, but cannot appear more than twice. value = obj. value. replace (". "," $ # $ "). replace (/\. /g ,""). replace ("$ # $ ",". ");}
The simple example of the above js method data verification is all the content shared by Alibaba Cloud xiaobian. I hope to give you a reference and support for the help house.