in reply to form validation
It should work if you remove the negation. Right now it says "if the username does not contain a non-alphanumeric character, generate an error", which is exactly the opposite of what you want. Remove the "!" and it should be corrected.
Also, remember that \w in Perl regular expressions represents the "alphanumeric plus underscore" class, exactly the class you used, and \W represents its complement. So you could do the test like this:
IMHO it is clearer and safer to check that the string contains only valid characters, instead of checking if it contains invalid ones. Like this:if ($FORM{username} =~ /\W/) { &error; } else { &proceed; }
if ($FORM{username} =~ /^\w+$/) { &proceed; } else { &error; }
--ZZamboni
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: form validation
by perlmonkey (Hermit) on May 10, 2000 at 06:25 UTC |