1
I’m validating the data field, the fact is that I’m not getting the size of the field, see:
<form action="" onsubmit="return valida()">
<input type="text" name="data" id="data"/>
<input type="submit" name="cadastrar"/>
</form>
............
function valida()
{
var data = document.querySelector("#data");
if((data.value == "")||(data.length != 10))
{
alert("Informe uma data válida");
data.focus();
return false;
}
else
{
return true;
}
}
Even stating a correct date, type "12/12/2012", the function returns false.
Thanks, the true Return needs Else because it is part of another script, here I only took a piece, and as for the validation I know it is not enough yet.
– user122195
Blz. They were general tips. But the question is the lack of
.value
before the.length
.– Sam
Sorry, I didn’t know, I’ll mark them all.
– user122195