重写代码,部分参考或者说借鉴27楼的思路,先按正确的格式定义月份日期,再进行判断:- @echo off
- for /l %%i in (1,1,31) do (
- if %%i lss 10 (
- set @0%%i=1
- set #0%%i=1
- ) else (
- set @%%i=1
- if %%i leq 12 set #%%i=1
- )
- )
- :o
- set/p "md=Please Input the Date (MM/DD):"
- if not "%md://=%"=="%md%" goto :p
- for /f "tokens=1* delims=/" %%i in ("%md%") do (
- if defined #%%i if defined @%%j set n=1
- if defined n (
- if "%%i" equ "02" (
- if "%%j" geq "30" set n=
- ) else (
- for %%k in (04 06 09 11) do if "%%i" equ "%%k" if "%%j" equ "31" set n=
- )
- )
- )
- :p
- if not defined n echo,Input Error&goto :o
- echo,Input Correct
- pause
复制代码
|