Terminator wrote:Yeah I know, but with reg expr. should also work
That is true. However, I tested both your attempts against '113' and they both accepted it, so I am afraid that I cannot duplicate the problem.
What I can say is that the second one is flawed because it does not allow 0s at all, and yet allows numbers beyond 9999. It should be:
preg_match('/^[1-9]\d{0,3}$/', $value)
EDIT:
Terminator wrote:preg_match('/\d/', $value) worked also, however then I have the problem that you can also use a 0
To prevent leading 0s when matching in the range [0, 9999]:
preg_match('/^(0|[1-9]\d{0,3})$/', $value)