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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.