Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
61
rated 0 times [  64] [ 3]  / answers: 1 / hits: 24574  / 10 Years ago, tue, march 11, 2014, 12:00:00

I want to check if the password length is at least 8 characters or not, when the user leaves the password field or press tab key.
How can i do this?



My code for password is shown below.



<input type=password name=password id=pass1 placeholder=password/> 

More From » jquery

 Answers
7

Use the jquery blur method for this.



$('#pass1').on('blur', function(){
if(this.value.length < 8){ // checks the password value length
alert('You have entered less than 8 characters for password');
$(this).focus(); // focuses the current field.
return false; // stops the execution.
}
});


Fiddle for Demo


[#72056] Sunday, March 9, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
brynneg

Total Points: 205
Total Questions: 111
Total Answers: 112

Location: Djibouti
Member since Wed, Dec 8, 2021
2 Years ago
;