validating for alphanumeric, comma, apostrophe and hyphen
Posted: Thu May 25, 2006 12:37 pm
Pimptastic | Please use
Am I on the right track?
Any help is appreciated,
Gilles
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I created a function to validate the data of an html form. I only want users to type alphanumeric characters, commas, apostrophes and hyphen. Nothing else.
I just can't seem to figure out how to do it properly....
Here is the function that I created:Code: Select all
function is_alphanumeric($test) {
return (preg_match("/^[A-Za-z0-9\,'\-]+/", $test));
}Any help is appreciated,
Gilles
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]