
function is_email(email){
  re=/[\w\.]+@[\w\.]+\.\w{2,}/;
  if(!re.test(email)) return false;
  return true;
}

function check_form() {
  var theForm = document.warranty;
  if (theForm.firstName.value == 0)
    {  alert("Please enter your first name"); theForm.firstName.focus(); return(false); }
  if (theForm.lastName.value == 0)
    {  alert("Please enter your last name"); theForm.lastName.focus(); return(false); }
  if (theForm.address1.value == 0)
    {  alert("Please enter your address"); theForm.address1.focus(); return(false); }
  if (theForm.city.value == 0)
    {  alert("Please enter the city you live in"); theForm.city.focus(); return(false); }
  if (theForm.zipcode.value == 0)
    {  alert("Please enter the zipcode"); theForm.zipcode.focus(); return(false); }
  if (theForm.country.value == "dr" || theForm.country.value == "")
    {  alert("Please enter the country you live in"); theForm.country.focus(); return(false); }
  if (theForm.phone.value == 0)
    {  alert("Please enter your phone"); theForm.phone.focus(); return(false); }
  if (theForm.email.value == 0)
    {  alert("Please enter your email address"); theForm.email.focus(); return(false); }
  if (!is_email(theForm.email.value))
    {  
      alert("It seems your email address is not valid.\nPlease enter it again."); 
      theForm.email.focus(); 
      return(false); 
    }
  if (theForm.unit.value == 0)
    {  alert("Please enter the unit model"); theForm.unit.focus(); return(false); }
  if (theForm.date.value == 0)
    {  alert("Please enter the date of purchase"); theForm.date.focus(); return(false); }
  if (theForm.store.value == 0)
    {  
      alert("Please enter the store where the unit was purchased"); 
      theForm.store.focus(); 
      return(false); 
    }
  theForm.submit();
}
