Here's a regular expression test for password in javascript that will work well in classic ASP.
//Password validation
if(form.EmpPass.value==0)
{
alert("Password is missing.");
form.EmpPass.focus();
return false;
}
var errorCounter = 0;
var errorMsg = "";
var space = " " ;
var fieldname = form.EmpPass;
var fieldvalue = fieldname.value;
var fieldlength = fieldvalue.length;
if (!(fieldvalue.match(/\W+/)))
{
errorMsg += "\nPasswords must include at least one special character - #,@,%,!\n";
errorCounter += 1
}
if (!(fieldvalue.match(/\d/)))
{
errorMsg += "\nPasswords must include at least one number.\n";
errorCounter += 1
}
if (!(fieldvalue.match(/[a-z]/)))
{
errorMsg += "\nPasswords must include one or more lowercase letters.\n";
}
if (!(fieldlength >= 7))
{
errorMsg += "\nPasswords must be at least 7 characters long.\n";
errorCounter += 1
}
if (fieldvalue.indexOf(space) > -1)
{
errorMsg += "\nPasswords cannot include a space.\n";
errorCounter += 1
}
if (errorMsg != "")
{
if(errorCounter > 1)
{
msg = "Please correct the problems with your password.\n";
msg += "_________________________________________________ _____\n";
}
else
{
msg = "Please correct the problem with your password.\n";
msg += "_________________________________________________ _____\n";
}
errorMsg += alert(msg + errorMsg + "\n\n");
fieldname.focus();
return false;
}
//End of password validation.
|