<script language="JavaScript" type="text/javascript">
function check() {
  if (document.orderform.numberwidgets.length == 0) 
  {
    alert("You have not ordered any widgets!");
  }
  else if (document.orderform.forename.length <= 1) 
  {
    alert("You have not entered a valid Forename!");
  }
  else if (document.orderform.surname.length <= 1) 
  {
    alert("You have not entered a valid Surname!");
  }
  else if (document.orderform.address1.length < 10) 
  {
    alert("You have not entered a valid address!");
  }
  else if (document.orderform.town.length < 5) 
  {
    alert("You have not entered a valid Town!");
  }
  else if (document.orderform.county.length < 5) 
  {
    alert("You have not entered a valid County");
  }
  else if (isValidPostcode(document.orderform.postcode) == false) 
  {
    alert("The post code you have entered is not valid (if this function works!)");
  }
}
// the following function was found online at http://www.codingforums.com/archive/index.php?t-49925.html
function isValidPostcode(postcode) {
if (!/^[A-Z]{1,2}\d{1,2} \d[A-Z]{2}$/.test(postcode)) {
return false;
}
return true;
}