unit Unit5;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.Buttons,
  Vcl.Mask, Vcl.DBCtrls;

type
  TfUsersEdit = class(TForm)
    Panel1: TPanel;
    bbOk: TBitBtn;
    bbCancel: TBitBtn;
    Panel2: TPanel;
    DBEdit1: TDBEdit;
    Label1: TLabel;
    DBEdit2: TDBEdit;
    Label2: TLabel;
    GroupBox1: TGroupBox;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    rgRigths: TRadioGroup;
    procedure Edit1Change(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fUsersEdit: TfUsersEdit;

implementation

{$R *.dfm}

uses Unit4;

procedure TfUsersEdit.Edit1Change(Sender: TObject);
begin
  if ( (Edit1.Text <> '') AND (Edit1.Text <> Edit2.Text) ) then begin
    bbOk.Enabled := False;
    Edit1.Color := clRed;
    Edit2.Color := clRed;
  end
  else begin
    bbOk.Enabled := True;
    Edit1.Color := clWindow;
    Edit2.Color := clWindow;
  end;
end;

procedure TfUsersEdit.Edit2Change(Sender: TObject);
begin
  if (Edit1.Text = Edit2.Text) then begin
    bbOk.Enabled := True;
    Edit1.Color := clWindow;
    Edit2.Color := clWindow;
  end
  else begin
    bbOk.Enabled := False;
    Edit1.Color := clRed;
    Edit2.Color := clRed;
  end;
end;

procedure TfUsersEdit.FormShow(Sender: TObject);
begin
  Edit1.Text := '';
  Edit2.Text := '';
end;

end.
