user1808199
user1808199

Reputation: 47

In install4j configurable form, is it possible to enable a disabled Next button as soon as some value is entered in a text field?

In the configurable form I'm able to disable the Next button of the current form, using pre-activation script pesent in Screen Activation of it's properties by using

context.getWizardContext().setNextButtonEnabled(false); 

But I need to enable it as soon as the user enters some value in the username and password text field. I have tried enabling it by calling this method

context.getWizardContext().setNextButtonEnabled(true); 

from User Input->Validation Expression of the corresponding text field. But eventhough I am not able to acheive, what I wanted. Is there any possiblity of doing this in install4j ?

This is code that I have entered in validation Expression :

String username = context.getVariable("userName").toString().trim();
String password = context.getVariable("password").toString().trim();
if((username.equals(null)) || (username.isEmpty())) {
context.getWizardContext().setNextButtonEnabled(false);
}
else if((password.equals(null)) || (password.isEmpty())) {
context.getWizardContext().setNextButtonEnabled(false);
}
else {
context.getWizardContext().setNextButtonEnabled(true); 
}
return true;

I hope this code will not execute since I entered in the Validation Expression. But at which place the code have to be inserted so that as soon as user enters some value in username and password field, the Next button of this form will get enabled ?

Upvotes: 1

Views: 1232

Answers (1)

Ingo Kegel
Ingo Kegel

Reputation: 48015

The validation expression of the screen is only executed when the user clicks on the "Next" button. The "Text field" form component has two additional scripts that are executed earlier:

  • "Key validation expression" property -> Invoked after a single key is pressed

  • "Input validation expression" property -> Invoked when the text field loses focus

Upvotes: 3

Related Questions