这个题目我做出来 了,只是这样的话,就算写了密码,还是不能按确定按钮提交,鼠标一移到确定按钮就弹出窗口!!!
难道说只是为了练习
难道说只是为了练习
2016-08-08
一般都是提交的时候在验证吧
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>表单列表</title>
<script type="text/javascript">
// 验证输入不为空的脚本代码
function checkForm(form) {
if(form.username.value == "") {
alert("用户名不能为空!");
form.username.focus();
return false;
}
if(form.password.value == "") {
alert("密码不能为空!");
form.password.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<form method="post" action="save.php" onsubmit="return checkForm(this);">
<label for="username">用户名:</label>
<input type="text" name="username" id="username" valve=""><br/>
<label for="password">密码</label>
<input type="password"name="username" id="username" valve=""><br/>
<input type="submit" name="确定" id="submit" valve="">
<input type="reset" name="充值" id="reset" valve="">
</form>
</body>
</html>举报