JavaScript-常用以验证用户的输入
JavaScript-常用于验证用户的输入
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<center>
<body>
<h1>Java Script 代码</h1>
<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>
</center>
</html>
JavaScript 是世界上最流行的编程语言。
这门语言可用于 HTML 和 web,更可广泛用于服务器、PC、笔记本电脑、平板电脑和智能手机等设备。
JavaScript 是脚本语言
JavaScript 是一种轻量级的编程语言。
JavaScript 是可插入 HTML 页面的编程代码。
JavaScript 插入 HTML 页面后,可由所有的现代浏览器执行。
JavaScript 很容易学习。
常用于验证用户的输入:
<!DOCTYPE html>
<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<center>
<body>
<h1>Java Script 代码</h1>
<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>
</center>
</html>