首页 > 解决方案 > 禁止在 Inno Setup 自定义页面上输入空白和仅空格

问题描述

如果它只包含空格,有没有办法禁止用户输入?我已经尝试过这个解决方案:
Inno Setup - Create User Input Query Page with input length and format limit and use the input

但是,我不想要那个解决方案,因为它完全禁用 -space-。
例如,如果文本字段中的输入是“我的名字”,它将返回错误,因为 -space- 是不允许的。

标签: inno-setuppascalscript

解决方案


使用与以下相同的代码:
Inno Setup - Create User Input Query Page with input length and format limit and use the input

只需使用以下实现ValidateInput

function ValidateInput(Sender: TWizardPage): Boolean;
begin
  Result := True;

  if Trim(Page.Values[0]) = '' then
  begin
    MsgBox('Input cannot be empty.', mbError, MB_OK);
    Result := False;
  end;
end;

Trim功能是关键。


推荐阅读