Validate password size

0

People because this condition does not work ?? It's something simple but by not knowing javascript I'm catching up.

function QTDsenha(){
  var senha = document.getElementById('idSenha');
    if(senha.value < 6){
        alert('Informe uma senha com no mínimo 6 caracteres');
    }    
}
<output>Senha<output>
<input id="idSenha" onblur="return QTDsenha()">
    
asked by anonymous 27.01.2018 / 21:54

1 answer

2

Why did not get the% size of the field:

function QTDsenha(){
  var senha = document.getElementById('idSenha');
    if(senha.value.length < 6){
        alert('Informe uma senha com no mínimo 6 caracteres');
        return false;
    }
}
<output>Senha<output>
<input id="idSenha" onblur="return QTDsenha()">
    
27.01.2018 / 22:01