Menu

Email Validation in Demo 3.0

Help
2008-03-06
2013-06-03
  • Sportsman Fishing Adventures

    Is it possible to make sure the email address provided in the form I created using the demo version 3.0 is a valid one as right now when I test I can add any email format I wish (test@test.com for example) and the form processes without checking to see if the email address is a valid one.  It just checks to make sure the structure is correct ie: test@test.com instead of test.test.com.
    Nootkan

     
    • TNTEverett

      TNTEverett - 2008-03-06

      It is possible however it is more difficult and not all hosts can be checked using a single method.  It is best checked by sending the email and waiting for a return rejection or failure notice via your own email account.  When the rejection is confirmed you can delete the entry from your database. 
      If you are serious about adding this feature you can Google the term "php email send validat".  There is plenty of discussion and example code. 

       
    • Tom Landon

      Tom Landon - 2008-08-20

      I'm also using the online 3.0beta.
      I have an e-mail field set to required.
      When testing the form...

      1. If I leave the field empty, the form processes, and, the resulting e-mail field is blank.

      2. If I enter an invalid address, the validation catches it.

      Here's the e-mail validation code.

                      else if(fieldType == 'email')
                      {   
                          if((required == 1 && fieldObj.value=='')  ||  (fieldObj.value!=''  && !validate_email(fieldObj.value)))
                          {               
                              fieldObj.setAttribute("class","mainFormError");
                              fieldObj.setAttribute("className","mainFormError");
                              fieldObj.focus();
                              return false;                   
                          }

                      }

                  }

                  function validate_email(emailStr)
                  {       
                      apos=emailStr.indexOf("@");
                      dotpos=emailStr.lastIndexOf(".");

                      if (apos<1||dotpos-apos<2)

      What code need I add to provide an error return on a blank e-mail submit?

      Thanks
                      {
                          return false;
                      }
                      else
                      {
                          return true;
                      }
                  }

       
      • TNTEverett

        TNTEverett - 2008-08-21

        The first if statement says it all.
        if((required == 1 && fieldObj.value=='')

        return false; 
        }

        If required and the value is blank, return false.  I am not sure why you are having this issue but you can insert some debugging to identify why this happens. 
        Right before the if statement, put in the following.

        alert("Required: "+required+"\nEmail Value :"+fieldObj.value);

         
    • Tom Landon

      Tom Landon - 2008-08-21

      Here's the amended code. Didn't make any difference.

                      else if(fieldType == 'email')
      alert("Required: "+required+"\nEmail Value :"+fieldObj.value);
                          {   
                          if((required == 1 && fieldObj.value=='')  ||  (fieldObj.value!=''  && !validate_email(fieldObj.value)))
                          {               
                              fieldObj.setAttribute("class","mainFormError");
                              fieldObj.setAttribute("className","mainFormError");
                              fieldObj.focus();
                              return false;                   
                          }

                      }

                  }

                  function validate_email(emailStr)
                  {       
                      apos=emailStr.indexOf("@");
                      dotpos=emailStr.lastIndexOf(".");

                      if (apos<1||dotpos-apos<2)
                      {
                          return false;
                      }
                      else
                      {
                          return true;
                      }
                  }

      Unless I screwed this up, I don't know what's going on. If you wish, check the function at: http://www.paganinstitute.org/form/45996/form.html.

      Also, if you want, I can send you the original .zip file.

      The server is Linux/Apache with php installed, as I'm running other forms (without Captcha) just fine. I'm getting heavily spammed, and, need the non-human filtering.

      Thanks,

      Tom

       
      • TNTEverett

        TNTEverett - 2008-08-21

        #1 it is not required so it won't check to see if it is blank.
        #2 the online form does not have the alert code I gave you so you won't see the debug info.

        Find this code at the bottom of your form:
        if (validateField('field_1','fieldBox_1','email',0) == false)
        Change to this:
        if (validateField('field_1','fieldBox_1','email',1) == false)

         
    • Tom Landon

      Tom Landon - 2008-08-21

      Thanks, that worked!

      By the way, I'm not likely to ever become a serious php programmer, but, I need to learn at least the basics. Do you have a suggestion of a good free online course/tutorial?

      Thanks again,

      Tom

       
      • TNTEverett

        TNTEverett - 2008-08-21

        Great that it works but learning PHP won't help you find these issues. 
        #1 you failed to select "required" when you generated the form.
        #2 the required feature uses java not php

        FYI
        http://www.w3schools.com/PHP/DEfaULT.asP

        http://www.learnphp.org/

        http://www.php.net/

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.