Delphi 5 - Date Field Validation and Trapping

I have a date input field that I want to validate that the contents REALLY are a date :-).

So the OnExit event reads:

procedure TForm1.Purchases_Postings_DateExit(Sender: TObject);
     Except On EConvertError Do
                ShowMessage('Please enter a valid date.');

Where Form1.Purchases_Postings_Date.text is the input field.

However before this gets called I get the message:

Project TEST.EXE raised exception class EConvertError with message '99/99/9999' is not a valid date. Process stopped. Use stop or run to continue.

And 99/99/9999 is a suitibly suicidal bogus date.

With thanks.
Who is Participating?
Hi edhasted

Seems that you are checking it in Delphi environment.
If you build the .Exe and try to tun it you will see that Delphi does not generateany error
and only displays your message. In fact while we (programmers) are programming the 'Error' is shown to let us handle
those errors but for users who execute the .exe file only the exception happens.

Good Luck
edhastedAuthor Commented:
The topic seems to have petered out without answering the original question about how in the code you trap a valid date.

Bringing up an error message is one way but it's not trapopoing the problem at source.

I believe this is effect unanswered which is a pity as I am sure Delphi must have a means of doing this.

If I have missed the point I would be delighted to know.

With best wishes and thanks to everyone who has contributed.

Hello again edhasted

well, I am not very sure about my english, may be i cannot explain it correctly, but when you prepare your executable file and leave the Delphi environment, the error message of delphi will not appear and  only your 'Error handler module' will be executed in which you will give your suitable message and your user may understand that he has to enter the date field in the way you are waiting for.

Good luck
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.