Check the validity of dates

Posted in Algorithms

Use StrToDate function and try ... except construction:

procedure TForm1.Button1Click(Sender: TObject);
begin
  try
    StrToDate(MaskEdit1.Text);
    Label2.Caption:='Valid Date';
  except
    on EConvertError do Label2.Caption:='Not Valid Date';
  end;
end;