Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

AEM FORMS : Trigger validation of another field programatically

DIPEN_SEN_
Level 3
Level 3

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?
3 Replies
Sakshi1
Level 3
Level 3

>> 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
Level 3

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.

lesutton1
Level 3
Level 3

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.