Cordial greeting,
I have problems trying to validate the form to send a form to the servlet, I'm going to validate by JavaScript, but even if I return false to the form on the onsubmit tag, the same form is processed in the servlet. I clarify that you already verify that you correctly enter the conditional that returns the false by means of an alert, but still the form is processed again.
Thank you very much for your attention.
HTML:
<form action="<%=request.getContextPath()%>/RegistrarVehiculoServlet" method="POST" onsubmit="validarForm()"> . . .</form>
JS:
function validarForm(){
var placa = document.getElementById('placa').value;
var marca = document.getElementById('marca').value;
var modelo = document.getElementById('modelo').value;
var fecha = document.getElementById('fechaIngreso').value;
if (placa === "" || marca === "" || modelo === "" || fecha === "") {
alert("Completa todos los campos");
return false;
}else{ return true;}