function validateForm() {

  // load the data into local variables
  var name = document.getElementById('name');
  var phone = document.getElementById('phone');
  var email = document.getElementById('email');
  var company = document.getElementById('company');
  var product;
  if (document.getElementById("product_SM")) {
    product = true;
  } else {
    product = false;
  }
   
   // check that the name has been entered.
   if (name.value == '' || name.value == "Name") {
     alert('Please enter a name.');
     name.focus();
     return false;
   }

   // check that a company has been entered        
   if (company.value == '' 
    || company.value == "Company" 
    || company.value == "Company name" 
    || company.value == "Company / NPO") {
     alert('Please enter a company name.');
     company.focus();
     return false;
   }
       
   // Check that an email has been entered.
   if (email.value == '' || email.value == "Email") {
     alert('Please enter an email address.');
     email.focus();
     return false;
   }
      
   // Check that email is valid.
   if (!isValidEmail(email.value)) {
     alert('Please enter a valid email address.');
     email.focus();
     return false;
   }

    // check that a phone number has been entered             
   if (phone.value == '' || phone.value == "Phone") {
     alert ('Please enter a contact number.');
     phone.focus();
     return false;
   }
     
   // Check for valid phone number (just check for invliad characters)
   phone.value = phone.value.replace(/[^0-9]/g,'');
   if (isNaN(phone.value)) {
     alert('Please enter a valid phone number.');
     phone.focus();
     return false;
   }

   // Check that a product was chosen (only if the products are options)
   if (product) {
     if (!document.getElementById('product_SM').checked
      && !document.getElementById('product_WebSMS').checked
      && !document.getElementById('product_E2S').checked
      && !document.getElementById('product_API').checked) {
       alert('Please select the product you are interested in.');
       return false;
      }
   }
          
   return true;
}
 
 //function to check valid email address
 function isValidEmail(strEmail){
   validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
    // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) {
      return false;
    } 
    return true; 
 }
