
function check() {
var pge = document.enq;

  // make sure they enter their name
  if (pge.cname.value.length == 0)
    {
    alert("Please enter your name.");
    pge.cname.focus();
    return false;
    }

    //check telephone number
  if (pge.tel.value == "") {
    alert("Please enter a telephone number");
    pge.tel.focus();
    return false;
     }

  // check to see if the email's valid
  if (!validEmail(pge.email.value)) {
    alert("We require a valid email address.");
    pge.email.focus();
    return false;
    }

  // check for a message
  if (pge.msg.value.length < 5) {
	      alert("You do not appear to have anything to say.");
	      pge.msg.focus();
	      return false;
    }

  // If we made it to here, everything's valid, so return true
  return true;
  }



function validateAdd() {
	var pge = document.deladd;

	  // make sure they enter their name
	  if (pge.contact.value.length < 5)
	    {
	    alert("We require a contact name.");
	    pge.contact.focus();
	    return false;
	    }
	  // make sure they enter their address
	  	  if (pge.add1.value.length < 2)
	  	    {
	  	    alert("We require an address.");
	  	    pge.add1.focus();
	  	    return false;
	    }
	  // make sure they enter their town
	  	  if (pge.town.value.length < 3)
	  	    {
	  	    alert("Please enter the town or city.");
	  	    pge.town.focus();
	  	    return false;
	    }
	  // make sure they enter their postcode
	  	  if (pge.pc.value.length < 5)
	  	    {
	  	    alert("We require a postcode.");
	  	    pge.pc.focus();
	  	    return false;
	    }

	    //check telephone number
	  if (pge.tel.value == "") {
	    alert("Please enter your contact telephone number");
	    pge.tel.focus();
	    return false;
	     }

	  // check to see if the email's valid
	  if (!validEmail(pge.email.value)) {
	    alert("We require a valid email address.");
	    pge.email.focus();
	    return false;
	    }

	  // If we made it to here, everything's valid, so return true
  return true;


}




// EMail Checker

function validEmail(email) {
  invalidChars = " /:,;"

  if (email == "") {// cannot be empty
    return false;
  }
  for (i=0; i<invalidChars.length; i++) {  // does it contain any invalid characters?
    badChar = invalidChars.charAt(i)
    if (email.indexOf(badChar,0) > -1) {
      return false;
    }
  }
  atPos = email.indexOf("@",1)// there must be one "@" symbol
  if (atPos == -1) {
    return false;
  }
  if (email.indexOf("@",atPos+1) != -1) {  // and only one "@" symbol
    return false;
  }
  periodPos = email.indexOf(".",atPos)
  if (periodPos == -1) {// and at least one "." after the "@"
    return false;
  }
  if (periodPos+3 > email.length) {// must be at least 2 characters after the "."
    return false;
  }
  return true;
}

