How can I add my own validation to the form

  • Profile Image
    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

  • Profile Image
    david
    Answered on January 22, 2016 at 01: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

     

     

  • Profile Image
    sudipsaha
    Answered on January 22, 2016 at 02: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
    ...
  • Profile Image
    david
    Answered on January 22, 2016 at 03: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.

  • Profile Image
    sudipsaha
    Answered on January 22, 2016 at 04: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
    ...
  • Profile Image
    Kevin_G
    Answered on January 22, 2016 at 06:08 PM

    Hi,

    You will find the default validations on the top toolbar :

    You may also add a mask to your field : 

    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.