Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6013103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:30:01+00:00 2026-05-23T02:30:01+00:00

I have an inputbox and would like the user to enter a password, but

  • 0

I have an inputbox and would like the user to enter a password, but at the same time hide it.

Is this possible?

This is my code so far:

var password : string;
begin
 password := InputBox('Password: ', 'Please enter your password: ', password)
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:30:02+00:00Added an answer on May 23, 2026 at 2:30 am

    You ‘cannot’ use InputBox for this, because, well… clearly this function doesn’t hide the text.

    The standard Windows edit control has a ‘password mode’, though. To test this, simply add a TEdit to a form and set its PasswordChar to *.

    If you want to use such an edit in an input box, you have to write this dialog yourself, like my ‘super input dialog’:

    type
      TMultiInputBox = class
      strict private
        class var
          frm: TForm;
          lbl: TLabel;
          edt: TEdit;
          btnOK,
          btnCancel: TButton;
          shp: TShape;
          FMin, FMax: integer;
          FTitle, FText: string;
        class procedure SetupDialog;
        class procedure ValidateInput(Sender: TObject);
      public
        class function TextInputBox(AOwner: TCustomForm; const ATitle,
          AText: string; var Value: string): boolean;
        class function NumInputBox(AOwner: TCustomForm; const ATitle,
          AText: string; AMin, AMax: integer; var Value: integer): boolean;
        class function PasswordInputBox(AOwner: TCustomForm; const ATitle,
          AText: string; var Value: string): boolean;
      end;
    
    class procedure TMultiInputBox.SetupDialog;
    begin
      frm.Caption := FTitle;
      frm.Width := 512;
      frm.Position := poOwnerFormCenter;
      frm.BorderStyle := bsDialog;
      lbl := TLabel.Create(frm);
      lbl.Parent := frm;
      lbl.Left := 8;
      lbl.Top := 8;
      lbl.Width := frm.ClientWidth - 16;
      lbl.Caption := FText;
      edt := TEdit.Create(frm);
      edt.Parent := frm;
      edt.Top := lbl.Top + lbl.Height + 8;
      edt.Left := 8;
      edt.Width := frm.ClientWidth - 16;
      btnOK := TButton.Create(frm);
      btnOK.Parent := frm;
      btnOK.Default := true;
      btnOK.Caption := 'OK';
      btnOK.ModalResult := mrOk;
      btnCancel := TButton.Create(frm);
      btnCancel.Parent := frm;
      btnCancel.Cancel := true;
      btnCancel.Caption := 'Cancel';
      btnCancel.ModalResult := mrCancel;
      btnCancel.Top := edt.Top + edt.Height + 16;
      btnCancel.Left := frm.ClientWidth - btnCancel.Width - 8;
      btnOK.Top := btnCancel.Top;
      btnOK.Left := btnCancel.Left - btnOK.Width - 4;
      frm.ClientHeight := btnOK.Top + btnOK.Height + 8;
      shp := TShape.Create(frm);
      shp.Parent := frm;
      shp.Brush.Color := clWhite;
      shp.Pen.Style := psClear;
      shp.Shape := stRectangle;
      shp.Align := alTop;
      shp.Height := btnOK.Top - 8;
      shp.SendToBack;
    end;
    
    class function TMultiInputBox.TextInputBox(AOwner: TCustomForm; const ATitle,
      AText: string; var Value: string): boolean;
    begin
      FTitle := ATitle;
      FText := AText;
    
      frm := TForm.Create(AOwner);
      try
        SetupDialog;
        edt.NumbersOnly := false;
        edt.PasswordChar := #0;
        edt.Text := Value;
        edt.OnChange := nil;
        result := frm.ShowModal = mrOK;
        if result then Value := edt.Text;
      finally
        frm.Free;
      end;
    end;
    
    class function TMultiInputBox.PasswordInputBox(AOwner: TCustomForm;
      const ATitle, AText: string; var Value: string): boolean;
    begin
      FTitle := ATitle;
      FText := AText;
    
      frm := TForm.Create(AOwner);
      try
        SetupDialog;
        edt.NumbersOnly := false;
        edt.PasswordChar := '*';
        edt.Text := Value;
        edt.OnChange := nil;
        result := frm.ShowModal = mrOK;
        if result then Value := edt.Text;
      finally
        frm.Free;
      end;
    end;
    
    class procedure TMultiInputBox.ValidateInput(Sender: TObject);
    var
      n: integer;
    begin
      btnOK.Enabled := TryStrToInt(edt.Text, n) and InRange(n, FMin, FMax);
    end;
    
    class function TMultiInputBox.NumInputBox(AOwner: TCustomForm; const ATitle,
      AText: string; AMin, AMax: integer; var Value: integer): boolean;
    begin
      FMin := AMin;
      FMax := AMax;
      FTitle := ATitle;
      FText := AText;
    
      frm := TForm.Create(AOwner);
      try
        SetupDialog;
        edt.NumbersOnly := true;
        edt.PasswordChar := #0;
        edt.Text := IntToStr(value);
        edt.OnChange := ValidateInput;
        result := frm.ShowModal = mrOK;
        if result then Value := StrToInt(edt.Text);
      finally
        frm.Free;
      end;
    end;
    

    Try it:

    procedure TForm1.Button1Click(Sender: TObject);
    var
      str: string;
    begin
      str := '';
      if TMultiInputBox.PasswordInputBox(Self, 'Password',
        'Please enter your password:', str) then
        ShowMessageFmt('You entered %s.', [str]);
    end;
    

    Screenshot

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a text input box. Would like the user to enter a string in
id like to have an input box that a user can enter a search
I have a basic quantity field and would like to allow the user to
In this blog, http://www.bswebdev.com/2008/12/javascript-change-input-box-type-to-password/ I have found the following snippets for fixing change input
I have an input box. On mouseover, I would like a list is to
I'm working on an iPhone app and would like to have a simple text
Setup: I have attached an event handler on the WebBrowser control something like this...
I have a input box, and I would like to use vbscript or javascript
net website, i would like to implement forget password. I am using following steps
I have an inputbox and a link for SEARCH styled to look like a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.