// JavaScript Document

//función para chequear campos de texto vacío
function isEmpty(strfield1, strfield2, strfield3) {
//
strfield1 = document.forms[0].nombre.value 
strfield2 = document.forms[0].empresa.value
strfield3 = document.forms[0].telefono.value

  //comprueba NOMBRE
    if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
    {
    alert("\"Name\" is a mandatory field.\nPlease. Check it and tray to send the form again.")
    return false;
    }

  //comprueba EMPRESA
    if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
    {
    alert("\"Company\" is a mandatory field.\nPlease. Check it and tray to send the form again.")
    return false;
    }

  //comprueba TELEFONO
    if (strfield3 == "" || strfield3 == null || strfield3.charAt(0) == ' ')
    {
    alert("\"Telephone\" is a mandatory field.\nPlease. Check it and tray to send the form again.")
    return false;
    }
    return true;
}
//Fubnción para chequear una dirección de e-mail valida
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.forms[0].email.value;
	// busca expresiones regulares el texto del campo e-mail 
    if (strEmail.search(validRegExp) == -1) 
   {
      alert('A valid e-mail adress is required.\nPlease. Check it and tray to send the form again.');
      return false;
    } 
    return true; 
}
//Esta función realiza todas las funciones definidas en el evento submit
function check(form){
if (isEmpty(form.nombre)){
if (isEmpty(form.empresa)){
if (isEmpty(form.telefono)){
if (isValidEmail(form.email)){
		  return true;
		}
	  }
  }
}
return false;
}