Posted: 14 Feb 2020 15:43 EST Last activity: 18 Feb 2020 6:09 EST
Pega UI button to be enabled as text is entered in text box
I am trying to enable a button on the UI form, as soon text is entered in a text box.
Currently the user has to enter text in the text box, and then click away, for the button to become enabled/clickable.
I would of tried to add "on-change" as event but UI buttons don't have an option for on change either.
Any suggestions would be appreciated.
***Edited by Moderator Marissa to update Content Type from Discussion to Question; update platform capabilities***
While this is possible in theory, I would not recommend it. The default way Pega behaves is that values from text controls are committed to the clipboard in the OnChange event, and this event typically occurs on a focus change. Rethink your use case - why do you need to show/hide this button in the first place?
If there really is no way around it, here's how I would approach it. The general idea is as follows:
A visibility condition controls whether the button is visible or not
Every time the text changes, commit this value back to the Clipboard
In addition, a section containing the button is reloaded each time.
Note: it is imperative that the button is not contained within the same section as your text control, otherwise the cursor would be moved to the very beginning whenever the user types something.
Create a new section and embed it in your view. Add your button, and create the following visibility condition:
The condition itself is pretty straight-forward. Let's say your field is called Name:
Then, on your text control, create an action using the Any key event. Add a Post value and a Refresh-Other section action:
Save your work. Here's the result:
Again, I would NOT recommend this. Pega commits the value back each time your user types something.
I'm doing this on 8.4 but it should be fine with older releases.
Assuming the property of the input is .pyLabel...
On the button have a disable condition .pyLabel == '' and have it run on the client
Then on the text input, add an action with an event "Any key" and do a set value with .pyLabel from the property .pyLabel. This should force the client ClipboardPage to update and will enable/disable the button as they type.