How to switch off validation of a field using guidebridge? | Community
Skip to main content
Level 3
October 16, 2015

How to switch off validation of a field using guidebridge?

  • October 16, 2015
  • 1 reply
  • 3522 views

In an adaptive form I want to hide fields that are not relevant anymore because of values in other fields.

Example: In the country I live children have a legal representative until they're grown up. If on a form somebody enters a birth date which indicates that he's older than 18 years the field demanding the name of his legal representative becomes obsolete. Such a feature is what I understand by adaptive form!

The only way I've found so far to accomplish this is :

* do not use the mandatory flag (because a field is always mandatory even if it's not visible)

* check in field's validation expression whether it is visible at all: if it is visible check its value else validation expression returns true

What I would like is a way to switch validation off by guidebridge in a elementVisibleChanged event. Is this possible? (The guidebridge documentation is deceptively incomplete for such questions.)

Thank you,

Urs Hofmänner

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Adobe Employee
October 16, 2015

Hi 

You can use the validationsDisabled property of a Field to switch off validations. In your example, you can write in the value commit expression of the birthdate field 
 

if ( checkIsabove18 ) { // replace checkIsAbove18 with an actual check
    legalRepresentation.visible = false; // assuming the name of the legal representation field is legalRepresentation. If not change this with the actual name
    legalRepresentation.validationsDisabled = true;
} else {
   legalRepresentation.visible = true;

   legalRepresentation.validationsDisabled = false;

}

Hopefully it solves your problem.

Happy to Help
Varun Dua

urs_h_Author
Level 3
October 16, 2015

Hi Varun 

thanks a lot for your response.

I didn't know the field's validationsDisabled property.

I'm using in a generic way:

window.addEventListener("bridgeInitializeStart", function(event) { var gb = event.detail.guideBridge; gb.connect(function() { gb.on('elementVisibleChanged', function(event, data) { var widget = guideBridge .resolveNode(data.jsonModel.target.somExpression); if (widget.className == 'guidePanel' || widget.className == 'guideTextDraw') { return undefined; } if (data.jsonModel.newText) { widget.validationsDisabled = false; } else { widget.validationsDisabled = true; } }); }); });

With this code I can enable/disable validation depending on its visibility.

Regards,

Urs

Adobe Employee
October 16, 2015

Hi Urs,


May I know how you are hiding the field ? Are you using the Visible Expression or the Value Commit Expression. In your use case using Value Commit Expression will give better performance.

Regards
Varun