Html和js表单
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>先来算一个简单的算术</p>
<p>48+202=</p>
<form name="myform" action=js表单.js onsubmit="return is250()" method="POST">
<input type="text" name="fname">
<input type="submit" value="提交">
</form>
<script>
function is250(){
var x=document.forms["myform"]["fname"].value;
if(isNaN(x)){
document.write("数字啊,小傻瓜!")
/* alert("数字啊,小傻瓜!") */
} else{
if(x==250){
document.write("答对了,你就是250!")
} else {
document.write("这都算错,你真是我的小宝贝呢!")
}
}
}
</script>
</body>
</html>
也可用alert弹窗