
function check() {
var pge = document.enq;

  // make sure they enter their name
  if (pge.name.value.length == 0)
    {
    alert("Please enter your name.");
    pge.name.focus();
    return;
    }

    //check telephone number
  if (pge.tel.value == "") {
    alert("Please enter a telephone number");
    pge.tel.focus();
    return;
     }

  // check to see if the email's valid
  if (!validEmail(pge.email.value)) {
    alert("We require a valid email address.");
    pge.email.focus();
    return;
    }

  // If we made it to here, everything's valid, so return true
  pge.submit();
  }


function checkThis() {
var pge = document.cata;

  // make sure they enter their name
  if (pge.cname.value.length == 0)
    {
    alert("Please enter a contact name.");
    pge.cname.focus();
    return;
    }


  // check to see if the email's valid
  if (!validEmail(pge.eml.value)) {
    alert("We require a valid email address.");
    pge.eml.focus();
    return;
    }
    
    //check telephone number
  if (pge.tel.value == "") {
    alert("Please enter a telephone number");
    pge.tel.focus();
    return;
     }
     
    // make sure they enter their address
    if (pge.add1.value.length == 0)
      {
      alert("Please enter your address.");
      pge.add1.focus();
      return;
      }
      
      
    // make sure they enter their address
    if (pge.town.value.length == 0)
      {
      alert("Please enter your address.");
      pge.town.focus();
      return;
      }
      
    // make sure they enter their pc
    if (pge.pc.value.length == 0)
      {
      alert("Please enter your postcode.");
      pge.pc.focus();
      return;
      }


  // If we made it to here, everything's valid, so return true
  pge.submit();
  }

function checkThat() {
var pge = document.sample;

  // make sure they enter their name
  if (pge.cname.value.length == 0)
    {
    alert("Please enter a contact name.");
    pge.cname.focus();
    return;
    }


  // check to see if the email's valid
  if (!validEmail(pge.eml.value)) {
    alert("We require a valid email address.");
    pge.eml.focus();
    return;
    }
    
    //check telephone number
  if (pge.tel.value == "") {
    alert("Please enter a telephone number");
    pge.tel.focus();
    return;
     }
     
    // make sure they enter their address
    if (pge.add1.value.length == 0)
      {
      alert("Please enter your address.");
      pge.add1.focus();
      return;
      }
      
      
    // make sure they enter their address
    if (pge.town.value.length == 0)
      {
      alert("Please enter your town / city.");
      pge.town.focus();
      return;
      }
      
    // make sure they enter their pc
    if (pge.pc.value.length == 0)
      {
      alert("Please enter your postcode.");
      pge.pc.focus();
      return;
      }
      
    // make sure they enter a sample
    if (pge.samp1.value.length == 0 && pge.samp2.value.length == 0 && pge.samp3.value.length == 0)
      {
      alert("Please enter a sample code number.");
      pge.samp1.focus();
      return;
      }


  // If we made it to here, everything's valid, so return true
  pge.submit();
  }


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;
}
