Examples are as follows:
//Input tag can only have positive numbers <input onkeyup="this.value=this.value.replace(/[^1-9]/g,'')" >//Positive integers can only be entered 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, '')}}}//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 first, except for the numbers and .obj.value = obj.value.replace(/[^/d.]/g, "");//The first one must be guaranteed to be a number instead of .obj.value = obj.value.replace(/^/./g, "");//The only one appears, and no more than one.obj.value = obj.value.replace(//.{2,}/g, ".");//The only one appears, but no more than two obj.value = obj.value.replace(".", "$#$").replace(//./g, "");}The above simple example of data verification of js method is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.