判断double 或 float就行了,不用这么费劲吧

解决方案 »

  1.   

    就算是判断double不是也的有限定条件吗!
      

  2.   

    "^[0]|[0.]\\d{0,2}|[1-9]{1}\\d{0,11}|[0-9]{1}\\d{0,11}[.]\\d{0,2}$"看这个行不行
      

  3.   

    "^[0]$|^[0.]\\d{1,2}$|^[1-9]{1}\\d{0,11}$|^[1-9]{1}\\d{0,11}[.]\\d{1,2}$"刚才那个错了,用这个,我试过了.
    <html>
    <head><script>function check()
    {

    if(document.getElementById("txt").value.match("^[0]$|^[0.]\\d{1,2}$|^[1-9]{1}\\d{0,11}$|^[1-9]{1}\\d{0,11}[.]\\d{1,2}$"))
    {alert("success");}
    else{alert("failure");}
    }</script></head>
    <body>
    <form name="theform">
    <input type="text" id="txt"><input type="button" onClick="check();" value="submit">
    </form>
    </body></html>