jquery - javascript password meter not incrementing -


i know question here, dont think relates design pattern instead more @ stupidity.

there ridiculously simple solution this, i'm tired , it's starting me bit. i've fired in console , responds accordingly when type input , doesn't respond.

here's js

$(document).ready(function(){ var passwordstrength = function (element){     var password = element.val();     var strength = [ 'very weak', 'weak', 'better', 'strong', 'very strong' ];     var score   = 0;     // > 6     if (password.length > 6){          score+=1;     }     //has lower , uppercase          if ((password.match(/[a-z]/) ) && (password.match(/[a-z]/))){         score+=1;     }     //has number     if (password.match(/\d+/)){         score+=1;     }     //has special character     if (password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)){         score+=1;     }     //more 12 characters     if (password.length > 12){         score+=1;     }      $('#pwdstrtxt').text(strength[score]);     $('#pwdstrtxt').addclass('pwdtext'+score);     $('#pwdstrfill').addclass('pwdscore'+score); }  passwordstrength($('#pass'));  }); 

here's jsfiddle

ideally i'd load bar , text change dynamically dependant on input.

any appreciated :) thanks.

you have call event each time input modified, that:

$("#pass").on("keyup change", function() {     passwordstrength($(this)); }) 

i've updated jsfiddle


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -