You need to tell preg_match that there will be multiple characters.  Right
now, you're searching for one, and only one.

if (! preg_match ('/^[a-z0-9]+$/', $unchecked_text)) {


The "+" means one or more matches to the range in brackets.

-- tracy

On 1/4/03 9:03 AM, "Anders Thoresson" <[EMAIL PROTECTED]> wrote:

> 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
> 

-- 
Tracy F. Rotton
[EMAIL PROTECTED]
http://www.taupecat.com/

          "... I like the 49ers because they're pure of heart,
          Seattle because they've got something to prove,
          and the Raiders because they always cheat."
                                     -- Lisa Simpson, "Lisa the Greek"


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to