AEM FORMS : Trigger validation of another field programatically

Avatar

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
DIPEN1
Level 2

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

Avatar

Avatar
Boost 1
Level 2
Sakshi1
Level 2

Likes

2 likes

Total Posts

32 posts

Correct reply

9 solutions
Top badges earned
Boost 1
Affirm 5
Affirm 3
Affirm 1
View profile

Avatar
Boost 1
Level 2
Sakshi1
Level 2

Likes

2 likes

Total Posts

32 posts

Correct reply

9 solutions
Top badges earned
Boost 1
Affirm 5
Affirm 3
Affirm 1
View profile
Sakshi1
Level 2

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.

Avatar

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile

Avatar
Boost 5
Level 3
lesutton1
Level 3

Likes

9 likes

Total Posts

47 posts

Correct reply

14 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile
lesutton1
Level 3

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
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
DIPEN1
Level 2

Likes

2 likes

Total Posts

40 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
DIPEN1
Level 2

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.