CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
limiting fields to a certain character legnth

 



Zeke_D
Deleted

Nov 2, 2000, 7:30 PM

Post #1 of 4 (483 views)
limiting fields to a certain character legnth Can't Post

how do I make the code below also limit the $user field to 15 characters?
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


if ($user =~ /[^a-zA-Z0-9_]/) { $founderror = 2 ;
$message .= "<B>Usernames can contain only numbers, letters, and the underscore '_' character.</B><BR>";
$fontuser = "<I><FONT COLOR='#FF0000'>";
}
</pre><HR></BLOCKQUOTE>


sleuth
Enthusiast

Nov 2, 2000, 7:37 PM

Post #2 of 4 (483 views)
Re: limiting fields to a certain character legnth [In reply to] Can't Post

 
Hey Zeke_D,

Use the length function,

if ($user =~ /[^a-zA-Z0-9_]/ &#0124; &#0124; length($user) > 15) {
$founderror = 2 ;
$message .= "<B>Usernames can contain only numbers, letters, and the underscore '_' character.</B><BR>";
$fontuser = "<I><FONT COLOR='#FF0000'>";
}

Sleuth


Zeke_D
Deleted

Nov 2, 2000, 7:50 PM

Post #3 of 4 (483 views)
Re: limiting fields to a certain character legnth [In reply to] Can't Post

now to have a seperste error message for too many characters:
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


if (length($user) > 15) {
$founderror = 2 ;
$message .= "<B>Usernames must be less than 15 characters.</B><BR>";
$fontuser = "<I><FONT COLOR='#FF0000'>";
}
</pre><HR></BLOCKQUOTE>
that would work?


[This message has been edited by Zeke_D (edited 11-02-2000).]


sleuth
Enthusiast

Nov 2, 2000, 9:39 PM

Post #4 of 4 (483 views)
Re: limiting fields to a certain character legnth [In reply to] Can't Post

 
Yep, Sure Would,

Sleuth

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives