procedure TfrmMain.checkDateEX(edt: Tmaskedit);
var
iyear, imonth, iday: word;
begin
if edt.Text <> ' - - ' then
begin
iyear := strToint(copy(edt.Text, 1, 4));
imonth := strToint(copy(edt.Text, 6, 2));
iday := strToInt(copy(edt.Text, 9, 2));
if (iyear < 1930) then
begin
showmessage('非法日期,请重新输入!');
edt.SetFocus;
exit;
end
else
begin
if (imonth < 1) or (imonth > 12) then
begin
showmessage('非法日期,请重新输入!');
edt.SetFocus;
exit;
end;
if imonth = 2 then
begin
if ((iyear mod 4) = 0) or ((iyear mod 100) = 0) then
begin
if (iday > 29) or (iday < 1) then
begin
showmessage('非法日期,请重新输入!');
edt.SetFocus;
exit;
end;
end
else
begin
if (iday > 28) or (iday < 1) then
begin
showmessage('非法日期,请重新输入!');
edt.SetFocus;
exit;
end;
end;
end
else if (imonth = 1) or (imonth = 3) or (imonth = 5) or (imonth = 7) or
(imonth = 8) or (imonth = 10) or (imonth = 12) then
begin
if (iday > 31) or (iday < 1) then
begin
showmessage('非法日期,请重新输入!');
edt.SetFocus;
exit;
end;
end
else
begin
if (iday > 30) or (iday < 1) then
begin
showmessage('非法日期,请重新输入!');
edt.SetFocus;
exit;
end;
end;
end;
end;
end;