Solved How to exclude symbols from batch file user input?

Compaq Hp compaq 15.6
October 17, 2012 at 06:04:05
Specs: Windows 7, 4 gig ram, celeron 1.8 dual core
How to exclude symbols from batch file user input?
so far i have this,

":BEPA
echo Welcome, Please type your favoured screen-name below
set username= type your screen-name here please
set /P username=Type username: %=%
echo.%username% | findstr []-[] > nul
if not ErrorLevel 1 (
echo. ERROR: Your screen name cannot contain [ or ]. please try again.
goto BEPA
)
echo you have successfully logged in :)
"

as you can probably see i want to stop the characters [ and ] from being used, any help would be appreciated,

TheRelativeApe


See More: How to exclude symbols from batch file user input?

Report •

#1
October 17, 2012 at 07:04:52
✔ Best Answer
Doesn't look fancy but it gets the job done.
///Edit, managed to fit it into one line
:BEPA
cls
echo.
echo.Welcome, Please type your favoured screen-name below
echo.Type your screen-name here please
set username=?
set /P username=Type username:
echo %username% | find "[" && Goto :ERROR || echo %username% | find "]" && Goto :ERROR
echo.you have successfully logged in :)
pause > nul
Goto :BEPA
:ERROR
cls
echo. ERROR: Your screen name cannot contain [ or ]. please try again.
pause > nul
goto :BEPA


Report •
Related Solutions


Ask Question