Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/03/2013, 13:09
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Error validación de formulario

el nombre de la propiedad es length no lenght
Además la expresión regular para email tiene un fallo
Código:
<script type="text/javascript">
		function validacion(){
			nombre = document.getElementById("nombre").value;
			email = document.getElementById("email").value;
			asunto = document.getElementById("asunto").value;
			mensaje = document.getElementById("mensaje").value;
			var formato = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			if(nombre.length==0){
				alert('[ERROR] El campo nombre está incompleto'); return false;
			}
			else if(!(formato.test(email)) ){
				alert('[ERROR] La dirección de email no es válida'); return false;
			}
			else if(asunto==null || asunto.length==0 || /^\s+$/.test(asunto)){
				alert('[ERROR] El campo asunto está incompleto'); return false;
			}
			else if(mensaje==null || mensaje.length==0 || /^\s+$/.test(mensaje)){
				alert('[ERROR] No ha introducido ningún mensaje'); return false;
			}
			return true;
		}
	</script>
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.