0

当我尝试使用正确的用户名和错误的密码(密码大小写不同但字母相同)登录表单时,它正在登录。

当我尝试使用正确的密码和错误的用户名(用户名大小写不同但字母相同)登录表单时,它正在登录。

我需要停止登录,这意味着我怎样才能使它在密码中区分大小写。是否应该在创建表时在数据库中完成,或者我们可以在程序中完成。

登录.html

<!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=US-ASCII">
<title>User Login</title>
<style>
table {  
font-family: Arial;
font-size: 13px;
align: center;
border: 0px;
background-color: #F2F2F2;
margin-top: 55px;
cell-spacing: 10em;
}
</style>
<script type="text/javascript">
function validateForm() {
var id = document.signup.LoginId;
var password = document.signup.LoginPassword;

if(id.value == "") {
    window.alert("Error: Username should be filled out.");
    id.focus();
    return false;
}
re = /^\w+$/;
if(!re.test(id.value)) {
    window.alert ("Error: Username must contain only letters, numbers and underscores.");
    id.focus();
    return false;
}

if(id.length < 6) {
    window.alert("Error: Username must contain at least 6 charecters.");
    id.focus();
    return false;
}
if(id.length > 12) {
    window.alert("Error: Username must not be greater than 12 charecters.");
    id.focus();
    return false;
}

if(password.value != cpassword.value) {
    window.alert("Error: Password and confirm password should be same.");
    password.focus();
    return false;
}

if(password.value != "") {
    if(password.length < 6) {
        window.alert("Error: Password must contain at least 6 charecters.");
        password.focus();
        return false;
    }
    if(password.length > 12) {
        window.alert("Error: Password must not be greater than 12 charecters.");
        password.focus();
        return false;
    }
    if(password.value == id.value) {
        window.alert("Error: Password must be different from UserName.");
        password.focus();
        return false;
    }
    re = /[0-9]/;
    if(!re.test(password.value)) {
        window.alert("Error: Password must contain at least one number.");
        password.focus();
        return false;
    }
    re = /[a-z]/;
    if(!re.test(password.value)) {
        window.alert("Error: Password must contain at least one lowercase letter (a-z).");
        password.focus();
        return false;
    }
    re = /[A-Z]/;
    if(!re.test(password.value)) {
        window.alert("Error: Password must contain at least one uppercase letters (A-Z).");
        password.focus();
        return false;
    }
}else {
    window.alert("Error: Please check that you've entered your Password.");
    password.focus();
    return false;
}

if (id.value || password.value ! valid) {
    window.alert("The username and/or password are invalid. Please try again");
    id.focus();
    return false;
}
}

</script>
</head>
<body>
<form action="search" name="signup" onsubmit="return validateForm()">
<table cellpadding="5" align="center">
<tr>
<td colspan="2">
<p> If you are new User, please <a href="SignUp.html">SignUp</a>. If you already have an account then SignIn.</p>
</td>
 </tr>
<tr><td>Username</td>
<td><input type=text name=LoginId /></td></tr>
<tr><td>Password</td>
<td><input type=password name=LoginPassword /> </td></tr>
<tr><td colspan="2" align="center">
<input type=submit value=SignIn /></td></tr>
<tr><td colspan="2">If you forgot your password, <a href="ResetPassword"> Reset </a>your password.</td></tr>
</table>
</form>
</body>
</html>

示例:如果我的用户名是 sapankumar45,密码是 KumRekha23

如果我将这些详细信息输入为 sapankumar45 和 kumRekh23(它正在工作),或者如果我将这些详细信息输入为 SAPANkumar45 和 KumRekha23(那么它也可以工作。)

4

0 回答 0