
function verify()
{
  // This section just uses a simple regular expression to check the name
  // input box. It checks for one or more characters, a space and another
  // group of characters.
  if (document.user_info.first_name.value.search(/^.+$/)) {
    alert("Please be sure to include your FIRST and LAST name");
    return;
  }
  else if (document.user_info.last_name.value.search(/^.+$/)) {
    alert("Please be sure to include your FIRST and LAST name");
    return;
  }
  else if (document.user_info.address1.value.search(/^.+$/)) {
    alert("Please include your address");
    return;
  }
  else if (document.user_info.city.value.search(/^.+$/)) {
    alert("Please be sure to include your city");
    return;
  }
 // else if (document.user_info.zip_code.value.search(/^\d{5}(-\d{4}){0,1}$/)) {
 //   alert("Please be sure to include a valid zip code");
 //   return;
 // }
    
  // This section also uses a regular expression to check the email  input box.
  // It checks for one or more characters, then it checks for the email @
  // signifier, then another group of characters, then a full stop or period (.),
  // then for another group of characters.
  
  else if (document.user_info.email.value.search(/^.+@.+\..+$/)) {
    alert("Please include a valid email address!");
    return;
  }
  else {
    document.user_info.submit();
  }
}

function validateNewsletterEmail()
{
  if (document.newsletter.email.value.search(/^.+@.+\..+$/)) {
    alert("Please include a valid email address!");
    return;
  }
  else {
    document.newsletter.submit();
  }
}

function validateWeddingRegistry()
{
  var in_string = document.reg_form.emails.value.replace( /\s+$/g, "" );// strip trailing spaces
  in_string = in_string.replace( /,$/, "" ); //strip trailing comma
  if (in_string!="") {
    var string_array = in_string.split(",");
    for (var i=0; i < string_array.length; i++) {
      var addr = string_array[i];
      if (addr.search(/^.+@.+\..+$/)) {
        alert("One or more of the email addresses contain errors.  Check address spelling and make sure you remembered " +
              "to separate addresses with commas");
        return;
      }
    }
  }
  document.reg_form.submit();
}
