How can I add my own validation to the form

  • sudipsaha
    Asked on January 22, 2016 at 12:42 PM

    Hi,

     

    I created several forms with Jotform. I am trying to write validation function in javascript by adding the attribute onsubmit. The functions get fired when I submit the form, but the form still get submitted. I tried to work with the similar form which doesn't have any jotscript function and that works perfectly. Can you please advise how can I add validation function of my own in jotform.


    Thanks

    Sudip Saha

  • David JotForm Support
    Replied on January 22, 2016 at 1:44 PM

    Hi,

    It is not possible to add javascript directly in the form.  You can, however, get the full source code of your form and insert your validation in that code:

    http://www.jotform.com/help/104-How-to-get-the-Full-Source-Code-of-your-Form

     

     

  • sudipsaha
    Replied on January 22, 2016 at 2:45 PM
    Hi
    Thank you for your response. I am adding the validation function. But for
    some reason, the form get still submitted when onsubmit returns false.
    Thanks
    Sudip Saha
    ...
  • David JotForm Support
    Replied on January 22, 2016 at 3:46 PM

    I believe the form will still submit as long as it passes the JotForm validation.  Your validation requirements would not need to be met in order to complete the form.

  • sudipsaha
    Replied on January 22, 2016 at 4:45 PM
    Hi David,
    Thank you for your response. How can I add my validation requirement with
    the JotForm requirement. Is this possible?
    Thanks
    Sudip Saha
    ...
  • Kevin Support Team Lead
    Replied on January 22, 2016 at 6:08 PM

    Hi,

    You will find the default validations on the top toolbar :

    How can I add my own validation to the form Image 1 Screenshot 30

    You may also add a mask to your field : 

    How can I add my own validation to the form Image 2 Screenshot 41

    However, the mask does not avoid to submit the form, and as explained by my colleague, it's not possible to add your custom validation, since it's not possible to add custom Javascript codes.