validate
Restricting an input field to only numbers with preg_match_all() (PHP)
This is a pretty easy way to restrict a field to only numbers.
The \D in the preg match is short for [^0-9], which will match all characters, except 0-9.
I’m new to the regex, so there might be a better way to do this. But this works for me.