function myFormValidator(theForm)
{   

// checking for source field not to be empty
var radioSelected = false;
  for (i = 0;  i < theForm.a1.length;  i++)
 {
    if (theForm.a1[i].checked)
        radioSelected = true;
  }
  if (!radioSelected)
  {
    alert("Please select one of the options for Question 1.");
    theForm.a1[0].focus();
    return (false);
  }


//alert("validation");

if (theForm.t1.value.length < 1)
  {
    alert("Please enter your comments");
    theForm.t1.focus();
    return (false);
  }

if (theForm.t1.value.length > 600)
  {
    alert("Please enter at most 600 characters in the comments field.");
    theForm.t1.focus();
  return (false);
  }


// name validation
if (theForm.name.value.length <1)
        {
          alert("Please enter your name");
          theForm.name.focus();
          theForm.name.select();
          return (false);
  }
if (theForm.name.value.length > 20)
        {
          alert("Too many characters in the name field");
          theForm.name.focus();
          theForm.name.select();
          return (false);
  }

//email validation
if (theForm.email.value.length < 1)
    {
      alert("Please provide your email address.");
      theForm.email.focus();
      theForm.email.select();
      return (false);
  }

  if (theForm.email.value.length > 24)
  {
    alert("Please enter at most 24 characters in the \"email\" field.");
    theForm.email.focus();
    theForm.email.select();
    return (false);
  }

//  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ-_.1234567890@";
//  var checkStr = theForm.email.value;
//  var allValid = true;
//  for (i = 0;  i < checkStr.length;  i++)
//  {
//    ch = checkStr.charAt(i);
//    for (j = 0;  j < checkOK.length;  j++)
//      if (ch == checkOK.charAt(j))
//        break;
//    if (j == checkOK.length)
//    {
//      allValid = false;
//      break;
//    }
//  }
//  if (!allValid)
//  {
//    alert("Please enter only letter and \".,@\" characters in the \"email\" field.");
//    theForm.email.focus();
//    theForm.email.select();
//    return (false);
//  }


//alert("validation for email done; ");

//  if (theForm.phone.value.length < 1)
//      {
//        alert("Please provide your phone number.");
//        theForm.phone.focus();
//        return (false);
//  }

// validation for phone number below


if ((theForm.phone.value.length > 1) && (theForm.phone.value.length < 7))
        {
          alert("Please check your phone number in the phone field");
          theForm.phone.focus();
          theForm.phone.select();
          return (false);
  }
  
  if (theForm.phone.value.length > 12)
          {
            alert("Too many characters entered in the phone field");
            theForm.phone.focus();
            theForm.phone.select();
            return (false);
  }


// *
var checkOK = "1234567890-()";
    var checkStr = theForm.phone.value;
    var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
          break;
      if (j == checkOK.length)
      {
        allValid = false;
        break;
      }
    }
    if (!allValid)
    {
      alert("Please enter only digits and \"-,(,) \" characters in the \"phone\" field.");
      theForm.phone.focus();
      theForm.phone.select();
      return (false);
  }

  
 // *


  theForm.submit();

  return (true);

}

