El código del script encargado de realizar la validación es el siguiente:
Código:
el script se ejecuta con el evento onsubmit="return validacion()" dentro del formulario.<script language="JavaScript">
function validacion(){
nombre = document.getElementById("nombre").value;
email = document.getElementById("email").value;
asunto = document.getElementById("asunto").value;
mensaje = document.getElementById("mensaje").value;
if(nombre==null || nombre.lenght==0 || /^\s+$/.test(nombre)){
alert('[ERROR] El campo nombre está incompleto'); return false;
}
else if(!(/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)/.test(email)) ){
alert('[ERROR] La dirección de email no es válida'); return false;
}
else if(asunto==null || asunto.lenght==0 || /^\s+$/.test(asunto)){
alert('[ERROR] El campo asunto está incompleto'); return false;
}
else if(mensaje==null || mensaje.lenght==0 || /^\s+$/.test(mensaje)){
alert('[ERROR] No ha introducido ningún mensaje'); return false;
}
return true;
}
</script>
¿Alguien sabe por qué no funciona mi script?
Gracias de antemano



