如现实为2005-03-30,而不是2005-03-32?

解决方案 »

  1.   

    真巧 我这两天也在做这个  共同讨论  应该是在 onchange 时检测吧
      

  2.   

    设置MaskEdit1的EditMask属性=“9999/9999/99;0; ”(只输入双引号以内的内容0;后有一个空格)就ok。
      

  3.   

    procedure frmMain.medtTimeChange(Sender: TObject);
    var sRStr,stem1,stem2,stem3,stem4,stem5,stem6,stemH,stemM:string;
        iTem:byte;
        tin,e:integer;
    begin
          sRStr:=medtTime.EditText;
         // sold:=medtTime.EditText;
          stem1:='';                  //first
          stem1:=Copy(sRStr,1,1);
          Val(stem1,tin,e);
          if e=0 then
          if strtoInt(stem1)<=2 then
          begin
            stem2:='';             //second
            stem2:=Copy(sRStr,2,1);        Val(stem2,tin,e);
            if e=0 then
            if((Strtoint(stem1)<2)and(strtoInt(stem2)<=9))or((Strtoint(stem1)=2)and(strtoInt(stem2)<5))then
            begin
              stem3:='';
              stem3:=Copy(sRStr,4,1);
              stemH:=Copy(sRstr,1,2);
              Val(stem3,tin,e);
              if e=0 then
              if (strtoint(stemH)<25) and (strtoInt(stem3)<1) or (strtoint(stemH)<24) and (strtoInt(stem3)<6) then
              begin
                stem4:='';
                stem4:=Copy(sRStr,5,1);
                Val(stem4,tin,e);
                if e=0 then            if (StrToInt(stem3)<6) and (StrToInt(stem4)<=9) then
                begin
                    stem5:='';
                    stem5:=Copy(sRStr,7,1);
                    stemM:=Copy(sRstr,4,2);
                    Val(stem5,tin,e);
                    if e=0 then
                    if ( ( (strtoint(stemH)=24) and  (StrToInt(stemM)=0) and  (StrToInt(stem5)<1)) or
                       ((strtoint(stemH)<24) and  (StrToInt(stemM)=60) and (StrToInt(stem5)<1)) or
                       ((strtoint(stemH)<24) and  (StrToInt(stemM)<60) and (StrToInt(stem5)<6)))  then
                     begin
                       stem6:='';
                       stem6:=Copy(sRStr,8,1);
                       Val(stem6,tin,e);
                       if e=0 then
                       if ( ( (strtoint(stemH)=24) and  (StrToInt(stemM)=0) and  (StrToInt(stem6)<1)) or
                          ((strtoint(stemH)<24) and  (StrToInt(stemM)=60) and (StrToInt(stem5)<1)) or
                          ((strtoint(stemH)<24) and  (StrToInt(stemM)<60) and (StrToInt(stem5)<6)))  then sold:=medtTime.EditText
                       else  medtTime.EditText:=sold;
                     end
                    else medtTime.EditText:=sold;
                end //strtoInt(stem4)<7
               else medtTime.EditText:=sold;
              end //strtoInt(stem3)<7
             else medtTime.EditText:=sold;
            end  //strtoInt(stem3)<7
            else medtTime.EditText:=sold;
          end  //strtoInt(stem1)<=2)
          else  medtTime.EditText:=sold;
    end;
    可以实现 就是效果不好