I want to use this javascript but being able to hard code 3 users, so that those 3 are able to Login. I'm a newbie with javascript so yea. The below is the code i use for a single user login.
function validate(loginForm)
{
var booValid = true;
var strErrorMessage = "";
var minLength=5;
var maxLength=10;
if(loginForm.pword.value.length < minLength)
{
strErrorMessage = "password must at least 5 characters\n";
booValid=false;
}
if(loginForm.pword.value.length > maxLength)
{
strErrorMessage = "pasword must not more than 10 characters\n";
booValid=false;
}
if(loginForm.loginid.value.indexOf("[email protected]") == -1)
{
strErrorMessage = "Incorrect Login ID, Please try again\n";
booValid = false;
}
else if(loginForm.loginid.value.indexOf("[email protected]") == -1)
{
strErrorMessage = "Incorrect Login ID, Please try again\n";
booValid = false;
}
else if(loginForm.loginid.value.indexOf("[email protected]") == -1)
{
strErrorMessage = "Incorrect Login ID, Please try again\n";
booValid = false;
}
if(!booValid)
{
alert(strErrorMessage);
}
return booValid;
}
I've tried to use "else if" but still doesn't work. It says the users name is wrong.
I've also try as:
if(loginForm.pword.value.indexOf("[email protected]") == -1) || loginForm.pword.value.indexOf("[email protected]") == -1 || loginForm.pword.value.indexOf("[email protected]") == -1)
{
strErrorMessage = "Incorrect Login ID, Please try again\n";
booValid=false;
}
Please help!
"pasword must not more than 10 characters\n"— Why? On a related note: "hard code 3 users" — Why?? These questions are rhetorical of course, I don't think you can find an acceptable rationale for doing this.