Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

Can we trigger the all the form validations that happen on a form when the submit button is clicked

Avatar

Former Community Member

Hi,

Is there a way to trigger the validations and actions that happen on a form when the submit button is clicked - without actually calling the click event of the submit button?

To list it down in points: what we want to achieve.
a) Host the Pdf in IE.(embed in the html page).
b) Configure default field validation patterns and mandatory fields for the form.
c) Have a validate button outside the pdf on the html to call the pattern validations and mandatory check for all the fields on the form.
c) Run all the default validations and mandatory checks that happen when this validate button is called.
d) Get the XML with data and also get the validation and mandatory errors to be displayed outside the pdf on the html page.

we are able to get the xml data using xfa.data.saveXML() before validations, but stuck with trying to run the validations without using the submit button.

Any comments will be appreciated.

regards

vipin

1 Reply

Avatar

Former Community Member

You can use this command to cause the form to validate:

          root node of form.execValidate()

This will cause all of the validations in the form to run it will also return a true or false value based on whether the form passes the validation tests or not. So you can build a test something like this:

     if (form1.execValidate() == false){
           app.alert("There are validation errors!")
     } else {
           app.alert("Validation passed -  you can get the data now")
     }

Hope that helps

Paul