Jump to content

Login problem?


imperialized

Recommended Posts

Ok guys, I am definitely not the best at javascript, but I don't think this is a coding problem. My issue is this:

 

I am writing a registration script using jQuery to do immediate validation. It all works just fine, but I cant figure out the password thing.

 

//CHECK PASSWORD 
function password_check(){	
var password = $('#password').val();
var password1 = $('#password1').val();

if(password == "" || password.length < {
$('#password').css('border', '2px red solid');
$('#password_check').html("<img src='img/cross.png' id='cross' /> Password must be 8 characters!");
    } else {
        //Since password is long enough, color it green.
        $('#password').css('border', '2px green solid');
        $('#password_check').html("<img src='img/tick.png' id='tick' />");
        
        //Password is long enough, what about password1? Check em both now.
        if(password1 == "" || password1.length < {
        $('#password1').css('border', '2px red solid');
        $('#password1_check').html("<img src='img/cross.png' id='cross' /> Password must be 8 characters!");
        } else {
        //Passwords are both long enough, do they match?
            if(password != password1){
            $('#password1').css('border', '2px red solid');
            $('#password1_check').html("<img src='img/cross.png' id='cross' /> Passwords do not match!!");        
            } else {    
                $('#password1').css('border', '2px green solid');
                $('#password1_check').html("<img src='img/tick.png' id='tick' />");            
            }
        }
    }
}

 

All the code works, but is there a way for me to make it so that the verify password form does not become RED with an error until the user actually starts to type? With this code, as soon as password reaches 8 characters, it automatically errors the verify field.

Link to comment
https://forums.phpfreaks.com/topic/249928-login-problem/
Share on other sites

for your password input set the max length.

 

<input type="password" id="password" name="password" maxlength="8"/>
<input type="password" id="password1" name="password1" maxlength="8"/>

this is a good precautionary step.. but should not be used as the only safeguard, as it can be tampered with..

OP can you explain a little further as to why this is not working for you.. I looked through your code and it appears like it should be doing what you want it to.. if the password length is greater than 8 characters, it will be bordered red and a message will appear..

Link to comment
https://forums.phpfreaks.com/topic/249928-login-problem/#findComment-1282778
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.