procedure TFrmoverduty.ESdateSExit(Sender: TObject);
var dover:TDateTime;
begin
if ESdateS.Text<>'' then
begin
dover:=strtodatetime(ESdateS.text);
ESdateS.text:=datetimetostr(dover);
if ESdateS.Text<'1999-1-1' then
begin
showmessage('开始时间有误!');
ESdateS.SetFocus;
end;
end;
end;
function ValidDate(const s:String):Boolean;
begin
Result:=True;
try
StrToDate(s);
except
On EConvertError do Result:=False;
end;
end;
procedure TForm1.Edit1Exit(Sender: TObject);
begin
if not ValidDate(Edit1.Text) then
begin
Application.MessageBox('Date format error.',
PChar(Application.Title),mb_OK+mb_IconError);
Edit1.SetFocus;
end;
end;