required fields not validating on submit

  • Profile Image
    sdionne
    Asked on June 18, 2012 at 09:57 PM

    Hi, 

    I received a form submission (from a Google Ad click) today that was missing data in all of the fields. I was wondering how the submission could have gotten around the "required field" validation, but then when I tested it myself, I realized the problem. It does give me a "this field is required" or "enter a valid e-mail address" error message, but when I click submit, it still processes the submission. (Tested this in both Chrome and Firefox with similar results.) Any suggestions?

  • Profile Image
    jeanettebmz
    Answered on June 18, 2012 at 10:59 PM

    Since the form has been embedded using its full source code, I think this workaround might help :

    Insert this javascript code within your head tag:

     function validateForm()

    {

    var x=document.forms["form_21584975914163"]["q1_name"].value;

    if (x==null || x=="")

      {

      alert("Name must be filled out");

      return false;

    else

     

      }

    }

     

    //The function above could be called when the form is submitted, just place it withing your form tag

    <form class="jotform-form" action="http://submit.jotform.us/submit/21584975914163/" method="post" name="form_21584975914163" id="21584975914163" accept-charset="utf-8" onsubmit="return validateForm()" >

     

    =====================================================

    Another workaround would be to insert a dynamic javascript function

     

    Best regards

    Jeanette

  • Profile Image
    jeanettebmz
    Answered on June 18, 2012 at 11:02 PM

    Of course, that function is just an example, in your case you would need to add an Else, to validate email, phone, company and Title

    Please check this link

    Cheers!

    Jeanette