
//strip the html out of input text - used for both answer and email addr
 
 function Del(suspecttext)
 { a = suspecttext.indexOf("<");
   b = suspecttext.indexOf(">");
   len = suspecttext.length;
   c = suspecttext.substring(0, a);
   if(b == -1)
   b = a;
   d = suspecttext.substring((b + 1), len);
   suspecttext = c + d;
   tagCheck = suspecttext.indexOf("<");
   if(tagCheck != -1)  // if there was a less than sign
   suspecttext = Del(suspecttext);
   return suspecttext; //all HTML stripped out by now
 }

 function ValidateTheForm()
 {
  if (document.all.yourname.value == "")  {
        alert ("\n Please enter your name")
        document.all.yourname.focus();
        return false;                     }

   if (document.all.youremailaddress.value == ""  &&
       document.all.yourphonenumber.value  == "")   {
       document.all.yourphonenumber.focus();
       alert ("Please enter either a phone number or an email address")
	   return false;                               }

  if (document.all.topictodiscuss.value == ""){
        alert ("Please tell us what you would like to discuss")
        document.all.topictodiscuss.focus();
        return false;                          }

  if (document.all.youremailaddress.value != ""  &&
        (document.all.youremailaddress.value.length  < 9 ||
         document.all.youremailaddress.value.length  > 48)) {
        alert ("Your email address is either too long or too short")
        return false;                                       }

 if (document.all.youremailaddress.value != ""  &&
     (document.all.youremailaddress.value.indexOf ('@',0) == -1  ||
      document.all.youremailaddress.value.indexOf ('.',0) == -1))  {
      alert ("Your email address is not in a valid format")
      document.all.youremailaddress.focus();
      return false;                                                }
/*
 if (! preg_match( '/^[A-Za-z0-9!#$%&\'*+-/=?^_'{|}~]+@[A-Za-z0-9-]+(\.[AZa-z0-9-]+)+[A-Za-z]$/', document.all.youremailaddress.value.))
      { alert ("Your email address is not in a valid format. (4)")
        document.all.emailaddr.focus();
        return false;}
*/  

// Before accepting input data strip out all HTML tags
   beforetext = document.all.yourname.value;
   aftertext  = Del(beforetext);
   document.all.yourname.value = aftertext;

   beforetext = document.all.yourphonenumber.value;
   aftertext  = Del(beforetext);
   document.all.yourphonenumber.value = aftertext;

   beforetext = document.all.topictodiscuss.value;
   aftertext  = Del(beforetext);
   document.all.topictodiscuss.value = aftertext;

   beforetext = document.all.youremailaddress.value;
   aftertext  = Del(beforetext);
   document.all.youremailaddress.value = aftertext;

 return true;
 }
