SyntaxFix
Write A Post
Hire A Developer
Questions
You need to anchor the regex at the start and end of the string:
^[0-9]+$
Explanation:
^ # Start of string [0-9]+ # one or more digits 0-9 $ # End of string