I have in my form the date field that forces the user to just numbers and if other options are not selected it returns an alert. But my doubt is referring to the date field already quoted. How do I force the user to enter the 8 numbers of the date, and if he does not type, when giving submit, will he return an error as an alert?
Here's what I've got ready for agr:
function formatar(mascara, documento){
var i = documento.value.length;
var saida = mascara.substring(0,1);
var texto = mascara.substring(i);
if (event.keyCode < 48 || event.keyCode > 57) {
event.returnValue = false;
}
if (texto.substring(0,1) != saida){
documento.value += texto.substring(0,1);
}
}
<form class="got" method="GET" action="Dia_rtd.php" name="troca" onsubmit="return verifica()">
<input type="text" maxlength="10" placeholder="Data" name="Data_dd" OnKeyPress="formatar('##/##/####', this)" style="width:70px;"/>
<button class="css_btn_class" type="submit">Atualizar</button>
</form>