Highlighted

AEM FORMS : Trigger validation of another field programatically

Avatar

Avatar

DIPEN1

Avatar

DIPEN1

DIPEN1

21-04-2017

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?

Replies

Highlighted

Avatar

Avatar

Sakshi1

Avatar

Sakshi1

Sakshi1

24-04-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.

Highlighted

Avatar

Avatar

lesutton1

Avatar

lesutton1

lesutton1

25-04-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. 

Avatar

Avatar

DIPEN1

Avatar

DIPEN1

DIPEN1

26-04-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.