问题
I have this code working ...
procedure ValidatePage;
begin
WizardForm.NextButton.Enabled :=
(CompareText(InputPage6.Values[EditIndex2], 'Admin') <> 0);
end;
procedure EditChange(Sender: TObject);
begin
ValidatePage;
end;
procedure PageActivate(Sender: TWizardPage);
begin
ValidatePage;
end;
But I want to add more validations.
Example: If you have not allowed EX12345
or EX54321
.
WizardForm.NextButton.Enabled :=
(CompareText(InputPage6.Values[EditIndex2], 'EX12345') <> 0);
and
WizardForm.NextButton.Enabled :=
(CompareText(InputPage6.Values[EditIndex2], 'EX54321') <> 0);
回答1:
If I understand you correctly, you are asking how to combine multiple logical expressions into one. Use boolean operators, particularly and
operator.
procedure ValidatePage;
begin
WizardForm.NextButton.Enabled :=
(CompareText(InputPage6.Values[EditIndex2], 'EX12345') <> 0) and
(CompareText(InputPage6.Values[EditIndex2], 'EX54321') <> 0);
end;
Particularly if you are going to add even more options, you can optimize the code by storing the value into a local variable first:
procedure ValidatePage;
var
Value: string;
begin
Value := InputPage6.Values[EditIndex2];
WizardForm.NextButton.Enabled :=
(CompareText(Value, 'EX12345') <> 0) and
(CompareText(Value, 'EX54321') <> 0);
end;
来源:https://stackoverflow.com/questions/53761284/inno-setup-disable-next-button-using-multiple-validation-expressions-when-input