My Blog
My Personal Blog
Now viewing all posts in Programming

Restricting an input field to only numbers with preg_match_all() (PHP)

May 7th 2009

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.

I like to do all the validating [...]

Read On No Comments


Recent Comments