Search code examples
inno-setuppascalscript

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


Is there a way to disallow user input if it contains spaces only? I already tried this solution:
Inno Setup - Create User Input Query Page with input length and format limit and use the input

But, I don't want that solution because it disable -space- completely.
E.g. if input in text field is "my name" it will return error because -space- is not allowed.


Solution

  • Use the same code as in:
    Inno Setup - Create User Input Query Page with input length and format limit and use the input

    Just use this implementation of 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;
    

    The Trim function is the key.