常用验证

1.判断是否为数字

 

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

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

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



 

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

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

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


posted @ 2019-12-16 19:42  Cutelady  阅读(72)  评论(0编辑  收藏  举报