请问这段dreamweaver表单验证的代码 对吗?
<%@LANGUAGE="VBSCRIPT"CODEPAGE="936"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transiti...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language='JavaScript'>
function chkLogin()
{
var f = document.forms['forLogin'];
if(f.txtUser.value=='')
{
alert('请输入用户名');
f.txtUser.focus();
return false;
}
if(f.txtPwd.value =='')
{
alert('请输入密码');
f.txtPwd.focus();
reutrn false;
}
return true;
}
</script>
<body>
<form id="forLogin" name="forLogin" method="post" action="">
user:
<input name="txtUser" type="text" id="txtUser" />
pwd:
<input name="txtPwd" type="text" id="txtPwd" />
<input type="submit" name="Submit" onclick="return chkLogin();" value="提交" />
</form>
<p> </p>
</body>
</html>
为什么不输入数据,点击提交不显示错误信息呢? 展开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language='JavaScript'>
function chkLogin()
{
var f = document.forms['forLogin'];
if(f.txtUser.value=='')
{
alert('请输入用户名');
f.txtUser.focus();
return false;
}
if(f.txtPwd.value =='')
{
alert('请输入密码');
f.txtPwd.focus();
reutrn false;
}
return true;
}
</script>
<body>
<form id="forLogin" name="forLogin" method="post" action="">
user:
<input name="txtUser" type="text" id="txtUser" />
pwd:
<input name="txtPwd" type="text" id="txtPwd" />
<input type="submit" name="Submit" onclick="return chkLogin();" value="提交" />
</form>
<p> </p>
</body>
</html>
为什么不输入数据,点击提交不显示错误信息呢? 展开
展开全部
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language='JavaScript'>
function chkLogin()
{
var f = document.forms['forLogin'];
if(f.txtUser.value=='')
{
alert('请输入用户名');
f.txtUser.focus();
return false;
}
if(f.txtPwd.value =='')
{
alert('请输入密码');
f.txtPwd.focus();
return false;
}
return true;
}
</script>
<body>
<form id="forLogin" name="forLogin" method="post" action="">
user:
<input name="txtUser" type="text" id="txtUser" />
pwd:
<input name="txtPwd" type="text" id="txtPwd" />
<input type="submit" name="Submit" onclick="return chkLogin();" value="提交" />
</form>
<p> </p>
</body>
</html>
你的密码验证的返回写错叻。 return 写成reutrn叻。。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language='JavaScript'>
function chkLogin()
{
var f = document.forms['forLogin'];
if(f.txtUser.value=='')
{
alert('请输入用户名');
f.txtUser.focus();
return false;
}
if(f.txtPwd.value =='')
{
alert('请输入密码');
f.txtPwd.focus();
return false;
}
return true;
}
</script>
<body>
<form id="forLogin" name="forLogin" method="post" action="">
user:
<input name="txtUser" type="text" id="txtUser" />
pwd:
<input name="txtPwd" type="text" id="txtPwd" />
<input type="submit" name="Submit" onclick="return chkLogin();" value="提交" />
</form>
<p> </p>
</body>
</html>
你的密码验证的返回写错叻。 return 写成reutrn叻。。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询