function validateForm() {
  var name = document.getElementById('name');
  var phone = document.getElementById('phone');
  var email = document.getElementById('email');
  var company = document.getElementById('company');
  var product = document.getElementById("product");
   
   //cehck that data has being entered.
   if (name.value == '') {
     alert('Please enter a name.');
     name.focus();
     return false;
   }
    
   if (phone.value == '') {
     alert ('Please enter a contact number.');
     phone.focus();
     return false;
   }
     
   if (email.value == '') {
     alert('Please enter an email address.');
     email.focus();
     return false;
   }
      
   if (company.value == '') {
     alert('Please enter a company name.');
     company.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 email is valid.
   if (!isValidEmail(email.value)) {
     alert('Please enter a valid email address.');
     email.focus();
     return false;
   }
             
   // Check that a product was chosen
   var productSelected = false;
   if (product && product.value != "") {
     productSelected = true;
   } else {
     if (document.getElementById('product_SM').checked
      || document.getElementById('product_WebSMS').checked
      || document.getElementById('product_E2S').checked
      || document.getElementById('product_API').checked) {
      productSelected = true;
    }
   }
   if (!productSelected) {
     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; 
 }
