-
Password strength in mozilla
Hi All,
I have a problem with javascript in mozilla browser in showing password strength meter. Here is my code.,
<script type="text/javascript">
var minimum = 4;
var fair = 6;
var strength_label = Array( 'Too short', 'Weak', 'Fair', 'Medium', 'Strong', 'Very Strong' );
var strength_color = Array( '#FF0000', '#FF9900', '#FFCC33', '#99CC99', '#00CC33', '#006600' );
var strength_width = Array( '10', '20', '30', '50', '75', '100' );
function updatestrength( pw )
{
if(document.getElementById('password').value.length<15){
if(document.getElementById('password').value==''){
document.getElementById('strengthbar').style.width = 0+'%';
document.getElementById('strength').innerHTML = ' ' ;
}else{
if(!pw)
{
var pw = document.getElementById('password').value.toString();
}
if(!pw)
{
return false;
}
var strength = 0;
if( pw.length >= minimum )
{
strength = 1;
if(pw.length >= fair)
{
strength++;
}
if(/\d+/g.test(pw)){
strength++;
}
if(/\W+/g.test(pw)){
strength++;
}
if(/[a-z]+/g.test(pw) && /[A-Z]+/g.test(pw)){
strength++;
}
}
document.getElementById('strengthbar').style.width = strength_width[ strength ]+'%';
document.getElementById('strengthbar').style.backgroundColor = strength_color[ strength ];
document.getElementById('strength').innerHTML = strength_label[ strength ] + ' ' ;
}
}
}
<td><input type="password" name="password" id="password" cssClass="selwidth" maxlength="15" onkeyup="updatestrength(this.value);"/> </td>
<td align="right"><b><div id="strength" /></b></td>
<td align="left"><div id="strengthmeter"><div><div id="strengthbar"></div></div></div></td>
This works fine in IE but in mozilla when pressed shift key the meter not showing perfectly....any help appreciated...
-
when pressed shift key the meter not showing perfectly
In what way?
At least 98% of internet users' DNA is identical to that of chimpanzees
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
|
Bookmarks