javascript数字验证输入

  javascript数字验证功能:

<html>
<body>
<p>请输入数字。如果输入值不是数字,浏览器会弹出提示框。</p>

<input id="demo" type="text">

<script>
    function myFunction()
    {
        var x=document.getElementById("demo").value;
        if(x==""||isNaN(x))
	{
	    alert("Not Numeric");
	}
}
</script>

<button type="button" onclick="myFunction()">点击这里</button>

</body>
</html>
            

  

原文地址:https://www.cnblogs.com/SoftShine/p/3727898.html