Always when I do a javascript validation of a text box, to see if it is empty or not, I do it as follows:
function validar(){
var input = document.getElementById("texto");
if(input.value == ""){
alert("Preencha todos os campos em branco.")
}
}
However, today I discovered that this has a flaw, if the user leaves a space like this in the text box:
...andvalidatetheformwillnotrecognizeitasempty.
Whileitmightbepossibletodothis:
functionvalidar(){varinput=document.getElementById("texto");
if((input.value == "") || (input.value == " ")){
alert("Preencha todos os campos em branco.")
}
}
.. And knowing that there are such cool solutions, I need to know if you can check for any characters inside the text box. And a way to do it in pure javascript.