To make validation of date field, the fact is that I can not get 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 reporting a correct date, type "12/12/2012", the function returns false.