问题遇到的现象和发生背景
初学html,为什么无法弹窗
问题相关代码,请勿粘贴截图
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>新用户注册html实现</title>
<script type="text/javascript">
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(UserName,"用户名 必须填写!")==false)
{UserName.focus();return false}
if (validate_required(Pwd1,"密码 必须填写!")==false)
{Pwd1.focus();return false}
if (validate_required(Pwd2,"确认密码 必须填写!")==false)
{Pwd2.focus();return false}
if (validate_required(Email,"Email 必须填写!")==false)
{Email.focus();return false}
if(validate_equal(Pwd1,Pwd2,"密码必须一致!")==false)
{Pwd1.focus();return false}
}
}
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false}
else {return true}
}
}
function validate_equal(field1,field2,alerttxt)
{
if (field1.value!=field2.value)
{
alert(alerttxt);return false;
}
else{return true}
}
</script>
</head>
<body>
<form action="submitpage.html" onsubmit="return validate_form(this)" method="post">
<table border="1" align="center">
<tr>
<td colspan="2">用户注册</td>
<td></td>
</tr>
<tr>
<td>用户名</td>
<td><input type="text" name="Username" size="30"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="Pwd1" size="30"></td>
</tr>
<tr>
<td>确认密码</td>
<td><input type="password" name="Pwd2" size="30"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="Email" size="30"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="注册"></td>
</tr>
</table>
</form>
</body>
</html>