关于登录表单,如何做到客户端验证通不过就无法调用action所指定的asp文件呢?(见几行代码)
关于登录表单,如何做到客户端验证通不过就无法调用action所指定的asp文件呢?(见几行代码)
我对用户名和密码做了如果不输入就提示输入的验证,但是虽然有提示,但是提示后还是直接调用asp文件,各位老师请看一下,我的代码错在哪里,或在哪里加些东西。谢谢了。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>我的测试网页</title>
<!-- 下面是验证函数-->
<script language = "vbscript">
private function validatelogin()
dim strusername,strpassword
strusername = document.frmlogin.txtusername.value
strpassword = document.frmlogin.txtpassword.value
if (strusername) = "" then
alert ("请输入用户名!")
end if
if (strpassword) = "" then
alert ("请输入密码!")
end if
end function
</script>
</head>
<body>
<form action="verifyid.asp" method="post" name = "frmlogin"
onsubmit = "validatelogin()">
<label>用户名: </label>
<input name="txtusername" type="text" size = "15" maxlength = "15"><br>
<label>密码: </label>
<input name="txtpassword" type="password" size = "6" maxlength = "6"><br>
<input name="submit" type="submit" value = "提交" >
<input name="reset" type="reset" value="取消" >
</form>
</body>
</html>