>I have a script that is used for text messaging. I added a line of code to
>check to make sure that input is in a field before the message is sent. My
>code is as follows:
>
>if($b !~ m/^\w[\w\s]*\w$/) { $error .= "Enter a message <br> \n"; }
>
>This fails if the field has any punctuation characters. I have checked on
>www.perldoc.com but I seem to be going in the wrong direction. I only want
>it to check to make sure there is data in the field. I am not concerned
with
>what the data is. This is only to keep people from sending blank messages.
>My thought is that it's one of these, but I am not sure. \w, \W, \s, \S,
\d,

If all you are trying to do is check for blank messages (0 length), then
use:

    if (length($b) == 0) {$error .= "Enter a message <br> \n"}

or

    if (!(length($b)) {$error .= "Enter a message <br> \n"}

If you have a set of characters that are valid, and you just want to check
that one
or more of them is in the message, and that there aren't any other
characters, then
try:

    if ($b !~ /^[\w\s!?$%&+=-]+$/) {$error .= "Enter a message <br> \n"}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to