0
I have made a javascript to verify passwords (forte/normal/fra
ca)
the problem is that using the keyup in javascript every time a input receives value the password level is changed, need to make the password level is only changed logically when the input password receive value.
Javascript
function validaSenha() {
 $('input').on('keyup', function() {
  // Obtém a quantidade de caracteres do valor inserido no input.
  var length = $(this).val().length;
  // Por padrão, o texto será 'Força da senha', caso a quantidade
  // de caracteres seja menor que 1.
  var title = 'Força da senha';
  if (length > 0) {
    if (length <= 8)
      title = 'fraca';
    else if (length >=8  && length < 10)
      title = 'normal';
    else 
      title = 'forte';
  }
  // Altera o atributo título com a palavra que identifica força da senha.
  $('.password-strength').attr('title', title);
 });
}
HTML
<script type="text/javascript" src="js/senhaForte.js"></script> 
   <form name="formCadastro" class="formCadastro" method="post">
     <div class="input-field col s12">
        <i class="mdi-action-https prefix"></i> 
        <input id="senha" type="password" required name="senha" minlength="8" maxlength=32 class="validate" placeholder='Senha'  onkeydown="validaSenha()"/>
        <label for="senha">Senha</label>
        <span title='' class='password-strength'></span>
     </div>
    </form>