禁止在 Inno Setup 自定义页面上输入空白和纯空格

Disallow empty and spaces-only input on Inno Setup custom page

如果用户输入仅包含 space,是否有办法禁止用户输入? 我已经尝试过这个解决方案:

但是,我不想要那个解决方案,因为它会完全禁用 -space-。
例如。如果文本字段中的输入是 "my name" 它将 return 错误,因为 -space- 是不允许的。

使用与以下相同的代码:

只需使用 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 function是关键。