0

I have this project im working on and i have two password fields when each one gains focus it use a jquery show blind effect; that displays a password strength div below the password fields. Then when it lose focus it hides the password strength div. I want the password strength to remain open when i switch between both password fields.


$('input[type=password]').focus(function() {
$('#pswd_info').show("blind", { direction: "vertical" }, 1000);
    }).blur(function() {
       $('#pswd_info').hide("blind", { direction: "vertical" }, 1000);
    });


edited:

So i have spend some time trying to figure this out but i have. Here is my solution THANKS to Robert. Here is my solution.

$('input[type=password]').focus(function() {
            $('#pswd_info').show("blind", { direction: "vertical" }, 300);
        });

 $("input[type=password]").blur(function() {
            window.setTimeout(function(){
                if($(":focus").attr("type") != "password"){
                    $('#pswd_info').hide("blind", { direction: "vertical" }, 300);
                }
            },100);
        });

thanks everyone for your help.

Mike June Bug Captain
  • 1,013
  • 1
  • 7
  • 15

2 Answers2

2

Check document.ActiveElement and see if it's one of your two password fields. If it isn't, you can allow the .hide function to execute.

More info here: Is there a 'has focus' in JavaScript (or jQuery)?

Community
  • 1
  • 1
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
0

have you tried like this ... it just a suggestion ....

$('input[type=password]').live('keyup',function() {
$('#pswd_info').show("blind", { direction: "vertical" }, 1000);
    }).blur(function() {
       $('#pswd_info').hide("blind", { direction: "vertical" }, 1000);
    });
F25rT
  • 114
  • 1
  • 10