0
I’m performing a fixation exercise that asks for the following:
The count is not working, it is picking up as if the number is greater than 3, for example number 12, and not if it has MORE than 3 characters.
Code:
function modificarAmarelo(){
document.getElementById('mudar').style.backgroundColor = '#ffff00';
}
function perderFoco(){
document.getElementById('mudar').style.backgroundColor = '';
var caracteres = document.getElementById('mudar').value
if (caracteres < 3){
document.getElementById('mudar').style.backgroundColor = '#ff0000'
} else{
document.getElementById('mudar').style.backgroundColor = '#00ff00'
}
}
<input id="mudar" type="text" onfocus="modificarAmarelo()" onblur="perderFoco()">