<% @include file= "/web-inf/jsp/common/common.jsp"%><title> price entry limit </title><script type= "text/ JavaScript ">/*** Real-time dynamic force change user input * arg1 inputobject **/function Amount (th) {var regstrs= [[' ^0 (\\d+) $ ', ' $ '),//prohibit entry of the whole number of parts more than two, but the first 0[' [^\\d\\.] +$ ', '],//prohibit entry of any non-digital and point[ ‘\\. (\\d?) \\.+ ', '. $ '],//prohibit entry of more than two points[' ^ (\\d+\\.\\d{2}). + ', ' $ ']//prohibit entry of more than two decimal places "original" ]; for(i = 0; i < regstrs.length; i++) {var reg=NewREGEXP (regstrs[i][0]); Th.value= Th.value.replace (Reg, regstrs[i][1]); } } /*** After inputting, input mode loses focus and then makes judgment and force change, and 0 complement of decimal point * arg1 Inputobject * This function is very silly, I wrote it long ago, no optimization, but the function is very complete, you try to use * There's actually a faster JavaScript built-in function that can extract numbers from clutter: * parsefloat (' 10 '); **/function Overformat (th) {var v=Th.value; if(v = = "") { //v = ' 0.00 ';v = "; } Else if(v = = = ' 0 ') { //v = ' 0.00 ';v = "; } Else if(v = = = ' 0. ')) { //v = ' 0.00 ';v = "; } Else if(/^0+\d+\.? \d*.*$/. Test (v)) {v= V.replace (/^0+ (\d+\.? \d*). *$/, ' $ '); V=Inp.getrightpriceformat (v). Val; } Else if(/^0\.\d$/. Test (v)) {v= v + ' 0 '; } Else if(!/^\d+\.\d{2}$/. Test (v)) { if(/^\d+\.\d{2}.+/. Test (v)) {v= V.replace (/^ (\d+\.\d{2}). *$/, ' $ '); } Else if(/^\d+$/. Test (v)) {v= v + '. 00 '; } Else if(/^\d+\.$/. Test (v)) {v= v + ' 00 '; } Else if(/^\d+\.\d$/. Test (v)) {v= v + ' 0 '; } Else if(/^[^\d]+\d+\.? \d*$/. Test (v)) {v= V.replace (/^[^\d]+ (\d+\.? \d*) $/, ' $ '); } Else if(/\d+/. Test (v)) {v= V.replace (/^[^\d]* (\d+\.? \d*). *$/, ' $ '); Ty=false; } Else if(/^0+\d+\.? \d*$/. Test (v)) {v= V.replace (/^0+ (\d+\.? \d*) $/, ' $ '); Ty=false; } Else { //v = ' 0.00 ';//set default values when the user is not enteredv = "; }} Th.value=v; }</script>OnBlur= "Overformat (this)"/></body>Amount input Box controls a valid number with only two digits after the decimal point