473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Password Validation

i want to enforce that my password should have a combination of alphabets ,digits and one special character.
if all three are present then only it shuld be valid.

if a user enters only digits as a password, it should not accept.
same for the alphabets.

i want to do the validation in javascript.

please suggest ASAP.
Mar 20 '07 #1
1 1669
sani723
117 100+
may be this help u

<script type="text/javascript">

function checkForm(form)
{
if(form.username.value == "") {
alert("Error: Username cannot be blank!");
form.username.focus();
return false;
}
re = /^\w+$/;
if(!re.test(form.username.value)) {
alert("Error: Username must contain only letters, numbers and underscores!");
form.username.focus();
return false;
}

if(form.pwd1.value != "" && form.pwd1.value == form.pwd2.value) {
if(form.pwd1.value.length < 6) {
alert("Error: Password must contain at least six characters!");
form.pwd1.focus();
return false;
}
if(form.pwd1.value == form.username.value) {
alert("Error: Password must be different from Username!");
form.pwd1.focus();
return false;
}
re = /[0-9]/;
if(!re.test(form.pwd1.value)) {
alert("Error: password must contain at least one number (0-9)!");
form.pwd1.focus();
return false;
}
re = /[a-z]/;
if(!re.test(form.pwd1.value)) {
alert("Error: password must contain at least one lowercase letter (a-z)!");
form.pwd1.focus();
return false;
}
re = /[A-Z]/;
if(!re.test(form.pwd1.value)) {
alert("Error: password must contain at least one uppercase letter (A-Z)!");
form.pwd1.focus();
return false;
}
} else {
alert("Error: Please check that you've entered and confirmed your password!");
form.pwd1.focus();
return false;
}

alert("You entered a valid password: " + form.pwd1.value);
return true;
}

</script>
Mar 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Christian Carlsen | last post by:
Hello, I need to validate a password: In order for the password to be accepted the following requirements must be met: At least one uppercase character (position in password is irrelevant) At...
1
by: brijesh | last post by:
i am relatively new to javascript i am trying for a password validation code but iam not able to stop the page from loading the page when the password is wrong. the code is as below...
1
by: David Brown | last post by:
In ASP.NET 2.0, I am using the asp:login control, but I want to reduce the validation on the password. I dont want the user to have to put in a special character or a number etc. Is it...
0
by: bienwell | last post by:
Hi all, I need to write some patterns in ValidationExpression that match to a rule for the password validation while using the regularExpressionValidator. Here is the rule for the password: 1- ...
0
by: Steven | last post by:
Currently, I want to create a setup project which needs the user to input a specify password or validation code before installation. If the input password/validation code is not correct, the...
15
by: Eugene Anthony | last post by:
Is this method of validation for password and username considered to be secured. In my previous post I was given a solution that uses command object and the values are parsed by parameters. But the...
3
by: shwethatj | last post by:
My problem is lik this , I am trying to create a PHP registration form for a HR website , but i dont know how provide password validation i.e the password and confirmation password entered by the...
1
by: shwethatj | last post by:
My problem is lik this , I am trying to create a registration form using javascript for a HR website , but i dont know how to provide password validation i.e the password and confirmation password...
5
by: ahilar12 | last post by:
hi all, i wanted to check whether the password entered matches with the confirm password.either through javascript or through php.i have enclosed my code somebody help on this <html> ...
5
by: Farhan Choudry | last post by:
On a form in excel. A textbox allows the user to enter a password which is validated. However, the validation will only accept lowercase entry for the password. I am looking for a function that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.