Reputation: 125
How do I only accept the following values with user input?
i.e.
SET /P POSID=Enter POS Number:
SET test=1%POSID%
IF %test% EQU 11, 12, 13, 14, 15 (11-15) 21, 22, 23, 24,25 (21-25) GOTO POSIDGOOD
Upvotes: 0
Views: 41
Reputation: 67216
setlocal
for %%a in (11 12 13 14 15 21 22 23 24 25) do set valid[%%a]=true
SET /P POSID=Enter POS Number:
if defined valid[%POSID%] GOTO POSIDGOOD
echo bad posid
You may use the same variables of my previous answer:
if defined posNum[%POSID%] GOTO POSIDGOOD
Upvotes: 0
Reputation: 80113
for %%a in (11, 12, 13, 14, 15, 21, 22, 23, 24,25) do if "%posid%"=="%%a" GOTO POSIDGOOD
echo bad posid
Upvotes: 3