简体   繁体   中英

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM