[Django]-RegexValidator is not allowing 0-9 in CharField

8👍

The regular expression [^0-9] means to match a non-digit anywhere in the string. You probably meant to start with ^[0-9], which requires a digit at the start of the string. For a complete solution, I think you want ^[0-9]*$, which requires all characters in the string to be digits.

Leave a comment