Of course to ask more than once as they may make several mistakes you could try:
Code:
while read -p "Enter a number: " N && [[ ! $N =~ ^[0-9]{4}$ ]];do echo "try again";done
The other thing to consider is, what constitutes a number, ie what if they enter 0023
Whilst druuna is correct about read, you could tell bash that the variable is expecting an integer with:
This will return 0 for alpha starting strings but unfortunately blows up if it starts with a number and then contains alphas
and you would still need to test 4 digit boundary with >999 <10000