var tletraonumero       = /^([a-z]|\d|[.\-_@])+$/
var letra       = /^([a-z A-Z])+$/
var tmail               = /^.+\@.+\..+$/
var tnum 				= /^([0-9])+$/
function Valida(theForm)
{

  if (theForm.nombre.value.length < 4)
  { alert("El campo nombre requiere al menos 4 caracteres");
    theForm.nombre.focus();
    return (false);}

  if (theForm.nombre.value.length > 20)
  {alert("El campo nombre requiere como maximo 20 caracteres");
    theForm.nombre.focus();
    return (false);}

  if (!letra.test(theForm.nombre.value)) {
      alert("Solo se admiten letras");
      theForm.nombre.focus();
      return (false);
    }
	if (theForm.apellido.value.length < 4)
  { alert("El apellido nombre requiere al menos 4 caracteres");
    theForm.apellido.focus();
    return (false);}

  if (theForm.apellido.value.length > 20)
  {alert("El campo apellido requiere como maximo 20 caracteres");
    theForm.apellido.focus();
    return (false);}

  if (!letra.test(theForm.apellido.value)) {
      alert("Solo se admiten letras");
      theForm.apellido.focus();
      return (false);
    }
 if (theForm.mail.value=="") 
	{alert("El Campo E-Mail es obligatorio ");
      theForm.mail.focus();
      return (false);  
  }
    if (!tletraonumero.test(theForm.mail.value)) {
      alert("El campo no admite caracteres especiales");
      theForm.mail.focus();
      return (false);
    }
    if (!tmail.test(theForm.mail.value)) {
      alert("El formato no es valido");
      theForm.mail.focus();
      return (false);
    }	
	
	if (theForm.mail.value != theForm.mail2.value)
  {alert("Error las direcciones no coinciden");
    theForm.mail2.select();
    theForm.mail2.focus();
    return (false);} 
	if (theForm.telefono == "[object]"){	
   if (theForm.telefono.value.length != 9 || isNaN(Number(theForm.telefono.value)))
   { alert("El telefono es obligatoro el formato es '914597441'");
     theForm.telefono.focus();
     return (false);}
  }
	 if (theForm.matricula.value=="") 
	{alert("El Campo matricula es obligatorio ");
      theForm.matricula.focus();
      return (false);  
  }
	 if (theForm.modelo.value=="") 
	{alert("El Campo Marca Modelo es obligatorio ");
      theForm.modelo.focus();
      return (false);  
  }
		 if (theForm.aseguradora.value=="") 
	{alert("Seleccone su compaņia de seguro");
      theForm.aseguradora.focus();
      return (false);  
  }
		 if (theForm.hora.value=="") 
	{alert("Seleccone hora para la llamada");
      theForm.hora.focus();
      return (false);  
  }
  	 if (theForm.hora2.value=="") 
	{alert("Seleccone hora para la llamada");
      theForm.hora2.focus();
      return (false);  
  }
	
  return (true);
}
