Facebook Twitter Reset

This Tutorial Has Been Viewed 3,361 Times.

Check password strength using javascript

Here is simple method to check the password strength using javascript, just copy and paste the script given below in your registration field and customize it accordingly.Add this code below inside the body tags of your page.

Please make sure that when you just copy and paste the code given below do remember to change the quotes, it will be in ascii character while copying.Dont forget!!!!, if it is not changed the script wont work.

For example as you can see the quotes in the first line where the javascript is inside ” quotes and this one must be changed to double quotes when it is coped to your code.

<script language="javascript">
function passwordCheck()
{var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z]) (?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{6,}).*", "g");
var pwd = document.getElementById("password");
if (pwd.value.length==0) {
document.getElementById('check').innerHTML = 'Type Password';
} else if (false == enoughRegex.test(pwd.value)) {
document.getElementById('check').innerHTML = 'More Characters';
} else if (strongRegex.test(pwd.value)) {
document.getElementById('check').innerHTML = '<b><span style="color:green">
Strong!</span>';
} else if (mediumRegex.test(pwd.value)) {
document.getElementById('check').innerHTML = '</b><b><span style="color:orange">
Medium!</span>';
} else {
document.getElementById('check').innerHTML = '</b><b><span style="color:red">Weak!</span>';
}}
</b></script>
<input name="password" id="password" type="text" size="15" maxlength="20" onkeyup="return passwordCheck();" />
<span id="check">Type Password</span>

Thank you very much.

VN:F [1.9.13_1145]
Rating: 5.7/10 (6 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 2 votes)
Check password strength using javascript, 5.7 out of 10 based on 6 ratings

Incoming search terms:




You will also be interested in ,

No comments yet.

Leave a Comment

Spam protection by WP Captcha-Free

Affordable Seo PackagesSeo BlogEdu Backlinks
More in Mysql, PHP (116 of 129 articles)