I need to verify that the user has entered the date in two date fields.
<input type="text" name="data1"/>
<input type="text" name="data2"/>
How to solve this? If I put required in the field, it only works in chrome. But what about Firefox and Safari?
See @Renaro Santos
<script>
function validar(){
var data1= document.getElementById("dataInicio").value;
var data2= document.getElementById("dataFim").value;
if(data1 == "" || data2=""){
alert('Uma das datas esta vazia');
return false;
}
}
</script>
<form method="post" action="" onsubmit="validar()">
Data inicial<input type="text" id="dataInicio" name="dataInicio" required>
Data Final<input type="text" id="dataFim" name="dataFim" required>
<input type="submit" name="pesquisar" value="Pesquisar">
</form>