难道说只是为了练习
当然这里代码的主要意图是认识onmouseover事件,确实是只为了练习。
实际情况当然不会这么设计:会在弹出对话框之前进行判断,如果已经输入了内容,就不再弹出提示,此时可按下鼠标左键,确认提交。
一般都是提交的时候在验证吧
<!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>所以说没任何叼用
onmosuover的意思就是当鼠标经过时触发事件
其他部分的代码都是无用的
就是让你看onmouseover的效果
所以输入密码和提交部分都是没用的
逗着玩咯