案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<h1>我的第一段 JavaScript</h1>
6
7
<p>请输入数字。如果输入值不是数字,浏览器会弹出提示框。</p>
8
9
<input id="demo" type="text">
10
11
<script>
12
function myFunction()
13
{
14
var x=document.getElementById("demo").value;
15
if(x==""||isNaN(x))
16
    {
17
    alert("Not Numeric");
18
    }
19
}
20
</script>
21
22
<button type="button" onclick="myFunction()">点击这里</button>
23
24
</body>
25
</html>
26