希望能从这个代码里修改
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>登录界面</title>
</head>
<body>
<center>
<h1>
欢迎光临!
</h1>
</center>
<form name="form1" method="post" action="Verification.jsp"onsubmit="return userCheck()">
<table width="30%" height="144" border="0" align="center">
<tr>
<td width="19%">
用户名:
</td>
<td width="81%">
<label for="id"></label>
<input name="id" type="text" id="id" size="25"
maxlength="30" />
</td>
</tr>
<tr>
<td>
密码:
</td>
<td>
<label for="password"></label>
<input name="password" type="password" id="password" size="25"
maxlength="30" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" name="button" id="button" value="登录" />
<input type="button" value="注册" onClick="window.location.href='login.jsp'">
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</form>
</body>
<script language="javascript">
function check_login()
{
if(document.form1.username.value==''")/*document.表单名.文本域名.value==''"*/
{
alert("请检查用户名是否为空!");
return false;
}
if(document.form1.password.value==''"){
alert("请检查您的密码是否为空!");
return false
}
if(document.form1.password.value.length<6){
alert("您的密码长度小于6!");
return false
}
}
</script>
</html>
你自己是这样写的,所以js中要有验证函数userCheck;
function userCheck()
{
if(document.form1.username.value==''")/*document.表单名.文本域名.value==''"*/
{
alert("请检查用户名是否为空!");
return false;
}
if(document.form1.password.value==''"){
alert("请检查您的密码是否为空!");
return false
}
if(document.form1.password.value.length<6){
alert("您的密码长度小于6!");
return false
}
}追问
试了不行,还是直接跳转到失败的页面没有提示,是不是我登录的那个连接有问题
追答userCheck方法没有执行吗
追问没有,我按登录时直接跳转到Verification.jsp
追答onsubmit="return userCheck()">
改为
onsubmit="return userCheck();return false;">
试试
onsubmit="return userCheck();return false;">
function userCheck()
{
if(document.form1.username.value==''")/*document.表单名.文本域名.value==''"*/
{
看一下有没有改错?
靠,你用户名的id不是username啊
该怎么改?
追答
改成