This form allways submit, never javascript stop with the errors. What is wrong?
thanks in advance ;)
I put the onsubmit return valida(this).... and the javascript code seems well
<form name="formulario" id="formulario" method="POST" action="<%=request.getContextPath()%>/altaanuncio" onSubmit="return valida(this)">
function valida(f) {
if (f.marca.selectedIndex==0){
$('#errores').html('Seleccione la marca.');
f.marca.focus();
return false;
}
else if(f.garantia.value == ""){
$('#errores').html('Introduzca meses de garantía');
f.garantia.focus();
return false;
}
else if(f.pvpofertado.value == ""){
$('#errores').html('Introduzca el precio del coche');
f.pvpofertado.focus();
return false;
}
return true;
}
return valida(this)