Board index » delphi » edit mask for date field

edit mask for date field

Hi.  I am using Delphi 4 with an Oracle 7.3 back end.  I have date/time
fields in the database that I am editing using DBEdit fields.  Since I
need to require a 4 digit year  (Y2K you know), I would like to use an
edit mask.  The problem is that the field must also be able to be
cleared, i.e. set to an empty string.  If you use an edit mask, you
can't blank out the field because __/__/____ fails the mask validation.

Does anyone have a good way to require a specific input AND still be
able to clear a date field?      Thanks.

 

Re:edit mask for date field


Have you tried using RxLib's component set?  They have a DB aware component
that does just this.
Wayne
Quote
Jaye Peterman wrote:
> Hi.  I am using Delphi 4 with an Oracle 7.3 back end.  I have date/time
> fields in the database that I am editing using DBEdit fields.  Since I
> need to require a 4 digit year  (Y2K you know), I would like to use an
> edit mask.  The problem is that the field must also be able to be
> cleared, i.e. set to an empty string.  If you use an edit mask, you
> can't blank out the field because __/__/____ fails the mask validation.

> Does anyone have a good way to require a specific input AND still be
> able to clear a date field?      Thanks.

Re:edit mask for date field


Quote
Jaye Peterman wrote:
> I would like to use an
> edit mask.  The problem is that the field must also be able to be
> cleared, i.e. set to an empty string.  If you use an edit mask, you
> can't blank out the field because __/__/____ fails the mask validation.

> Does anyone have a good way to require a specific input AND still be
> able to clear a date field?      Thanks.

This is what I have done in the past... basically it changes the mask on
the fly based on whether the field is cleared or not... The OnChange event
for the TMaskEdit uses the following routine (you should be able to extend
it to support a 4 digit year)...

{-----------------------------------------------------------------------------}

procedure DateChange(Sender: TObject);
begin
  with Sender as TMaskEdit do
  begin
    if Text = '  /  /  ' then
      EditMask := '!99/99/99;1;_'
    else
      EditMask := '!99/99/00;1;_';
  end;
end;

{-----------------------------------------------------------------------------}

--
Eric

P.S. To reply via email, remove "NoSpam" from my reply address

Re:edit mask for date field


For the best date edit control with a drop down calendar, check out
http://www.softouchdev.com/products.html
Quote
Jaye Peterman wrote in message <35EC5A8A.789E8...@ibm.net>...
>Hi.  I am using Delphi 4 with an Oracle 7.3 back end.  I have date/time
>fields in the database that I am editing using DBEdit fields.  Since I
>need to require a 4 digit year  (Y2K you know), I would like to use an
>edit mask.  The problem is that the field must also be able to be
>cleared, i.e. set to an empty string.  If you use an edit mask, you
>can't blank out the field because __/__/____ fails the mask validation.

>Does anyone have a good way to require a specific input AND still be
>able to clear a date field?      Thanks.

Other Threads