   function text (str) { return /[0-9_;:!~?=+<|>]/g.test(str); }

   function numeric (str) { return /^[0-9-\+\(\)\s]+z/.test(str + "z"); }

   function mail (str) { return /^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z])+$/.test(str); }
   function checkForm () 
      {
      var title;
      var elem;
      var dutyField = "Не заполнено поле ";
      var wrongField = "Неверное значение поля ";
      var check = true;

      function checkError (field, str) 
         {
         document.getElementById("alert").innerHTML = str;
         check = false;
         }

      document.getElementById("alert").innerHTML = "";

      if (check)
         {
         elem = document.preview.theme.value;
         if (elem == 0) checkError('theme', 'Укажите свое имя');
         }

      if (check)
         {
         title = '"Фамилия"';
         elem = document.preview.name.value;
         if (elem.length == 0) checkError('name', dutyField + title);
         else if (text(elem)) checkError('name', wrongField + title);
         }
         
      if (check)
         {
         title = '"E-mail"';
         elem = document.preview.email.value;
         if (elem.length == 0) checkError('email', dutyField + title);
         else if (!mail(elem)) checkError('email', wrongField + title);
         }

      if (check)
         {
         title = '"Телефон"';
         elem = document.preview.phone.value;
         if (elem.length == 0) checkError('phone', dutyField + title);
         else if (!numeric(elem)) checkError('phone', wrongField + title);
         }
         
      if (check)
         {
         elem = document.preview.agree.value;
         if (!elem) checkError('agree', 'Напишите сообщение');
         }         
         
      if (check)  { document.preview.submit(); }

      return check;
      }