3 Replies Latest reply on Apr 26, 2017 7:26 AM by DIPEN

    AEM FORMS : Trigger validation of another field programatically

    DIPEN

      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?
        • 1. Re: AEM FORMS : Trigger validation of another field programatically
          Sakshi Level 2

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

          • 2. Re: AEM FORMS : Trigger validation of another field programatically
            lesutton1 Level 1

            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. 

            • 3. Re: AEM FORMS : Trigger validation of another field programatically
              DIPEN Level 1

              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.