14 Dec 2009 at 22:19 #1 swinnie swinnie Soldato Joined 30 Apr 2007 Posts 3,095 Location Kent Hi Guys, How would I validate a form field to ensure that the input is numbers and no other characters? Thanks
Hi Guys, How would I validate a form field to ensure that the input is numbers and no other characters? Thanks
14 Dec 2009 at 22:38 #2 sniffy sniffy Soldato Joined 12 Dec 2003 Posts 8,141 Location East Sussex http://php.net/manual/en/function.is-numeric.php
15 Dec 2009 at 00:13 #3 robmiller robmiller Soldato Joined 26 Dec 2003 Posts 16,522 Location London And if you want to strip non-numeric characters, instead of just determining whether the string contains them: Code: $string = preg_replace('/[^0-9]/', '', $string);
And if you want to strip non-numeric characters, instead of just determining whether the string contains them: Code: $string = preg_replace('/[^0-9]/', '', $string);