www.webdeveloper.com
Results 1 to 2 of 2

Thread: Password strength in mozilla

  1. #1
    Join Date
    Dec 2009
    Posts
    1

    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...

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    when pressed shift key the meter not showing perfectly
    In what way?

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
  •  
HTML5 Development Center



Recent Articles