I need to disable Next button, when input is not "Admin".
Something like:
procedure EditKeyPress(Sender: TObject; var Key: Char);
begin
{ enable the next button if the value in the box is admin; disable otherwise }
WizardForm.NextButton.Enabled:=InputPage6.values[EditIndex2].Text = 'Admin'
end;
Implement the input box OnChange
event. You will also need to make sure the button state is updated, when the custom page is activated. You can use OnActivate
event for that (or CurPageChanged
event function).
var
Page: TInputQueryWizardPage;
procedure ValidatePage;
begin
WizardForm.NextButton.Enabled := (CompareText(Page.Values[0], 'Admin') = 0);
end;
procedure EditChange(Sender: TObject);
begin
ValidatePage;
end;
procedure PageActivate(Sender: TWizardPage);
begin
ValidatePage;
end;
procedure InitializeWizard();
begin
Page := CreateInputQueryPage(...);
{ To disable the Next button initially [when box is empty] }
Page.OnActivate := @PageActivate;
Page.Add(..., False);
{ Update Next button state on any input change (typing, copy&paste, whatever) }
Page.Edits[0].OnChange := @EditChange;
end;
To combine multiple validations, see Inno Setup Disable Next button using multiple validation expressions (when input value matches one of multiple values).
For other approaches, see Inno Setup - Create User Input Query Page with input length and format limit and use the input.