<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>isNaN判断是不是数字</title>
<script type="text/javascript" src="http://cdn.gbtags.com/jquery/1.11.1/jquery.min.js"></script>
<style type="text/css">
</style>
</head>
<body>
<input type="text">
<input type="button" value="判断输入值是不是数字">
</body>
</html>
<script type="text/javascript">
window.onload=function (){
var aInput=document.getElementsByTagName("input");
aInput[1].onclick=function(){
var text=aInput[0].value;
if(isNaN(text)){
alert(text+"不是数字");
}else{
alert(text+"是数字");
}
}
}
</script>