<el-input ="isFloor"/>
//Positive number, including decimal number isFloor(e,type){ if(type=='floor') { var val=; //Limit only one decimal point if ((".") != -1) { var str = ((".") + 1); if ((".") != -1) { val = (0, (".") + (".") + 1); } } = (/[^\d^\.]+/g,''); } }, //Positive and negative numbers, including decimals isFloor(){ var obj=; var t = (0); = (".", "$#$")//Replace the first character '.' with '$#$' .replace(/\./g, "")//Replace the remaining characters '.' with empty .replace("$#$", ".")//Replace the character '$#$' back to the original '.' .replace(/[^\d.]/g, "")//Only enter numbers and '.' .replace(/^\./g, "")//Cannot start with '.' .replace( /([0-9]+\.[0-9]{2})[0-9]*/,"$1")//Only 2 decimal places are retained if (t == '-') { = '-' + ; } }
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.