<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="text" style="width:200px;height:30px;" id="name">
<script>
//验证用户输入的是否是数字
var reg = new RegExp("^[0-9]*$");
var obj = document.getElementById("name");
obj.onblur = function(){
console.log(reg.test(obj.value));
if(!reg.test(obj.value)){
alert("请输入数字")
}
}
// checkIsNum();
</script>
</body>
</html>