Gossamer Forum
Home : Products : DBMan : Customization :

Special Characters

Quote Reply
Special Characters
Hi,

is there a way I can disallow special characters in a field ?

I have a database converted from a .csv file, and deleted all special characters i.e. <> and pipes, but users can still add new records containing these characters and that causes problems in showing the records

Thanks



Quote Reply
Re: [Andrea1] Special Characters In reply to
my $user_input_string = "Some string that should not contain exclamation marks!";

my $unallowed_character = "!";

if ($user_input_string =~ /$unallowed_character/) { print "Hey, you used an unallowed character: <b>$unallowed_character</b>! Don't do it again!";}

It gets a bit more complicated when you have several unallowed characters, but that's the basic routine.
kellner
Quote Reply
Re: [kellner] Special Characters In reply to
You'll need \Q \E for the regex otherwise * $ ^ etc...will be ignored and / will probably cause errors