Expand my Community achievements bar.

Enable/Disable button based on text field change

Avatar

Level 2

Hi,

I'm trying to enable/disable the "Submit PMT ACN" button based on the user input. I've put code in change event of the field to activate the button but the the downside is that when user is typing in data into field, its loosing focus.

I tried to put in exit event but, the event is firing only when the user clicks somewhere outside of the field.

Disabled Button

Capture1.JPG

Enabled Button

Capture2.JPG

Can someone please help with some ideas to implement this?

Many thanks,
Sandeep

1 Reply

Avatar

Former Community Member

In the change event of the text field, assuming your button is named Button1 and var checkTest value is password:

var startVal = "";

var checkThis = "";

var checkTest = "password";

if (this.rawValue != null) {startVal = this.rawValue;}

checkThis = startVal + xfa.event.newText;

if (checkThis === checkTest || xfa.event.newText === checkTest) {

          xfa.host.messageBox("got");

          Button1.presence = "hidden";

}

else {

          Button1.presence = "visible";

}

this works by me (tested).

Hope it helps.