Password

by Chris Nicholson

HTML

<input type="password" /><input type="text" style="width: 15px" /><input type="password" /><input type="text" style="width: 15px" /><input type="password" />
<span id="length"></span>
<a href="#clear" id="clear">Clear</a>

JavaScript

$('#length').text('0');

$('input').keyup(function(){
    var length = 0;
    $('input').each(function(){
        length += $(this).val().length;
    });
    $('#length').text(length);
});

$('input[type=password]').keydown(function(){

    if($(this).val().length > 8){
        if($(this).next('input').val() !== undefined){
    
            $(this).attr('disabled', 'true');
            $(this).next('input').focus();
    
        }
    }
    
});

$('input[type=text]').keydown(function(){
   
    if($(this).val().length > 0){
        
        $(this).attr('disabled', 'true');
        $(this).next('input').focus();
        
    }
    
});

$('#clear').click(function(){
    
    $('input').val('').removeAttr('disabled');
    
});