help with preg_match
| From: | Anders Thoresson | Date: | Sat, 04 Jan 2003 17:03:52 +0000 |
| Subject: | help with preg_match | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-130231@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to write a function that validates the input in a textarea. I just want to allow alphanumrical characters, and if the user enters anything else, I display an error message by calling error().
But the following doesn't work. Even if I enter "hello" in the textarea, I get the error message. What am I missing?
// validate entered text in textarea
function validate_textarea($unchecked_text) {
if (!preg_match ("/^[a-zåäö0-9]$/is", $unchecked_text)) {
error("You have used unlegal characters, just alphanumeric is ok.");
}
}
Best regards,
Anders