重置页面,或者提交页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>returnModel</title>
<script type="text/javascript">
function mytest(){
var msg = "";
if (document.all.formNames.names.value=="") {
msg ="请输入用户名";
alert(msg);
document.all.formNames.names.focus();
return false;
};
if (document.all.formNames.passWord.value=="") {
msg ="请输入密码";
alert(msg);
document.all.formNames.passWord.focus();
return false;
};
alert("保存成功");
}
</script>
</head>
<body>
<center>
<form name="formNames" method="post" action="target.pag" onsubmit="return(mytest())">
用户:<input type="text" name="names" size="20">
密码:<input type="password" name="passWord" > <br>
<input type="submit" name="b1" value="提交">
<input type="reset" name="b2" value="重置">
</form>
</center>
</body>
</html>
解释说明: