<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original code by Peter Haydon -->
<!-- peter_haydon@lineone.net -->

<!-- Begin
function postit(){ //check postcode format is valid
 test = document.details.pcode.value; size = test.length
 test = test.toUpperCase(); //Change to uppercase
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }
  if (document.details.Name.value == '') {   
  alert('Missing Name!');   
  return false; 
  }
  if (document.details.Address.value == '') {   
  alert('Missing Address!');   
  return false; 
  }
  if (document.details.Tel.value == '') {   
  alert('Missing Telephone Number!');   
  return false; 
  }

email = document.details.Email.value
AtPos = email.indexOf("@")
StopPos = email.lastIndexOf(".")

if (AtPos == -1 || StopPos == -1) {
alert('Missing or Invalid Email address!');   
return false; 
}

 document.details.pcode.value = test; //write back to form field
 if (size < 6 || size > 8){ //Code length rule
  alert(test + " is not a valid postcode - wrong length");
  document.details.pcode.focus();
  return false;
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
   alert(test + " is not a valid postcode - cannot start with a number");
   document.details.pcode.focus();
   return false;
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
   alert(test + " is not a valid postcode - alpha character in wrong position");
   document.details.pcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   document.details.pcode.focus();
   return false;
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
   alert(test + " is not a valid postcode - number in wrong position");
   document.details.pcode.focus();
   return false;
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
   alert(test + " is not a valid postcode - no space or space in wrong position");
   document.details.pcode.focus();
   return false;
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
   alert(test + " is not a valid postcode - only one space allowed");
   document.details.pcode.focus();
   return false;
  }
return true;
}

//  End -->
