AEM FORMS : Trigger validation of another field programatically | Community
Skip to main content
DIPEN_SEN_
Level 3
April 22, 2017

AEM FORMS : Trigger validation of another field programatically

  • April 22, 2017
  • 2 replies
  • 3991 views

I have two scenario:

  1. I have two field. Field A and field B. I want to validate field B when A is changed and vice versa. So, how to trigger validation of particular form field when one field is changed?
  2. Validate rule applied when field is focus out. As a result, on click submit without focus out from a field, first field is validated and does not submit the form. On second click on submit it submits the form. How to handle this situation?
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Sakshi5
Adobe Employee
Adobe Employee
April 24, 2017

>> I have two field. Field A and field B. I want to validate field B when A is changed and vice versa. So, how to trigger validation of particular form field when one field is changed?

You have to make a validation rule for field B using field A and vice versa. We currently have support for revalidation of whole form, not individual fields. This you can configure with help of visual editor.

>> Validate rule applied when field is focus out. As a result, on click submit without focus out from a field, first field is validated and does not submit the form. On second click on submit it submits the form. How to handle this situation?

What is your AEM version? This works on AEM 6.3, i.e, i don't require a second click on submit.

DIPEN_SEN_
Level 3
April 26, 2017

Sakshi wrote...

>> I have two field. Field A and field B. I want to validate field B when A is changed and vice versa. So, how to trigger validation of particular form field when one field is changed?

You have to make a validation rule for field B using field A and vice versa. We currently have support for revalidation of whole form, not individual fields. This you can configure with help of visual editor.

>> Validate rule applied when field is focus out. As a result, on click submit without focus out from a field, first field is validated and does not submit the form. On second click on submit it submits the form. How to handle this situation?

What is your AEM version? This works on AEM 6.3, i.e, i don't require a second click on submit.

 

I am using AEM 6.2.

Adobe Employee
April 25, 2017

If you'd like to turn validations on and off and retest you can set the validationsDisabled property. For example, if you no longer want validation to fire on your second field, use vCurrentInstance.panelName.fieldName.validationsDisabled = true; (true disables validations). Then on the commit event of your first field, set the property to false to turn validation back on.