Expand my Community achievements bar.

How to cusomize validations on submit action in Adaptive Form

Avatar

Level 3

Hi , 

i have a requirement customize default error validation on Adaptive Form filed.

Problem: We have written custom validation method for email filed with onblur() event, but if user click on Submit method then my form is submitting with out calling my custom function.

I want to enable this call when user click on submit button, so that i can verify user data.

Can anyone guide me how to achieve this.

4 Replies

Avatar

Level 3

Hi
 

You can write the validation script on the validation event. If you are on 6.2 or 6.1 FP1 you can use the Rule Editor to add your validation logic using the Visual Editor

For more advance use case you can specify that using code editor where you can write any custom JavaScript 

For more information on rule editor please visit [1]

[1] https://helpx.adobe.com/aem-forms/6-1/rule-editor.html

Avatar

Level 3

Hi Varundua,

If i opt for rule editor its form Level and i can not re-use the validation, I would like to apply validations at component level. So that author can configure it.

Is there possibility for component level validations?

Avatar

Level 3

If you'd like to create a library of JavaScript files (and CSS) that apply to your forms then Client Libraries are the best approach. It's likely one of the most powerful features that you inherit when upgrading to AEM Forms from LiveCycle.

https://docs.adobe.com/docs/en/aem/6-2/develop/the-basics/clientlibs.html

Client Libs can be added to any number of forms and allow you to create standard libraries of features and functionality across your forms. Things like email, web, phone number validations can be added using the rule editor to make a call to your standard functions. 

Avatar

Level 2

Hi,

By using the rule editor, the validation script can be added for individual components as well. You can open the rule editor for the component on which you want to apply the script, or you can also select the required component from the form model tree available in the rule editor. When the submit button is clicked, it runs the validations on every component. If you've written a custom validation script, then that script will also get called.