in reply to Reasonable RegExps
It might be easier on your users, as well as on whoever picks up the code later to split the check into pieces--separating out the length checks, for example. This lets you tailor error messages. Also, consider inverting the test so that you're detecting anything that's not legal.
Something like the following untested fragment might work for you:
my $len = length($sup_fullname); if ( $len == 0 ) { $message .= "<p>You must provide a Full Name.</p>"; $found_err = 1; } elsif ( $len > 30 ) { $message .= "<p>Full Name is limited to 30 characters.</p>"; $found_err = 1; } elsif ( $sup_fullname =~ /[^-.'\w\s]) { $message .= "<p>Full Name cannot contain special symbols</p>"; $found_err = 1; }
Take extra care to not insult people who have full names longer than 30 characters. I know of two such people.
|
|---|