Posted 28 September 2012 - 11:17 AM
Hello. I'm trying to create a while loop where the user must input a number into the computer, and check it for validation. My problem is, I can't figure out how to make it so that the input MUST be a number. Specifically, I want it to be a seven digit number. I have no problems when the input must be one of a few specific words, but I don't know how to set it so that the entry must be a number. Here's a segment of my code:
print("To Proceed, Please Validate Your Identity:")
print("")
while true do
write("Personal Identification Number: ")
id = read()
if id == ??? a 7 digit number ??? then
break
else
print("Invalid Entry")
print("Your ID# Must Be A 7 Digit Number")
sleep(2)
term.setCursorPos(1,5)
term.clearLine()
term.setCursorPos(1,4)
term.clearLine()
term.setCursorPos(1,3)
term.clearLine()
end
end
I don't care what number the user inputs, so long as it is seven digits long. I'd really appreciate any assistance :P/>/>
print("To Proceed, Please Validate Your Identity:")
print("")
while true do
write("Personal Identification Number: ")
id = read()
if id == ??? a 7 digit number ??? then
break
else
print("Invalid Entry")
print("Your ID# Must Be A 7 Digit Number")
sleep(2)
term.setCursorPos(1,5)
term.clearLine()
term.setCursorPos(1,4)
term.clearLine()
term.setCursorPos(1,3)
term.clearLine()
end
end
I don't care what number the user inputs, so long as it is seven digits long. I'd really appreciate any assistance :P/>/>