B
Bill W
Guest
I have a form in PHP and I only want to allow users to input letters, digits and commas. Currently I can make sure the input only has letters and numbers:
if (! eregi("^[a-zA-Z0-9]*$", $_POST["myinput"]) ) {
echo "This field only allows letters, numbers and commas.";
}
How do I change this to also only allow commas in the input? So this would be acceptable:
fishing, boating, 1and1
But this would return an error, because it has characters other than letters, numbers and commas in it:
"hi there", _boats, *me*
if (! eregi("^[a-zA-Z0-9]*$", $_POST["myinput"]) ) {
echo "This field only allows letters, numbers and commas.";
}
How do I change this to also only allow commas in the input? So this would be acceptable:
fishing, boating, 1and1
But this would return an error, because it has characters other than letters, numbers and commas in it:
"hi there", _boats, *me*