。。

解决方案 »

  1.   

    兼容小数点
    <html>
    <head>
    <title>JS Test</title>
    <script language="javascript">
     function ff(obj,pid){
        var value = obj.value;
        if(value.match(/^((([1-9]|[1-2][0-9])(\.[0-9]+)?)||30)$/))
    {
    alert("success");
    } else {
    alert("failed")
    }
        document.getElementById(pid).innerHTML = value;
     }
    </script
    </head>
    <body>
    <form>
    <div id="text"></div>
    <textarea id="findValue" onblur="ff(this, 'text');" ></textarea>
    </form>
    </body>
    <html>