Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

allowing only a-z, 0-9 2

Status
Not open for further replies.

blitzer

Programmer
Jun 18, 2001
34
CA
how do i parse so a form variable only submits if it consists solely of numbers and letters (a-z, A-Z, 0-9)? I'm sure there's already a thread which answers this but the search on this forum isn't working..

thanks,
-blitz
 
Well, if you are talking about validating form input BEFORE the form is submitted, then you are talking about JavaScript. Other forum.

If you are talking about validating AFTER the form is submitted, and the data makes it to the server, then here you go:
Code:
use CGI;

my $cgi = new CGI;

print $cgi->header();

$someParam = $cgi->param('someParam');

if($someParam =~ /[^a-zA-Z0-9]/){
        print "Invalid input";
        }
else{
        print "Input was OK!";
        }

Hope that helps...

--jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top