programming-examples/perl/CGI/Process form with regular expression- date.pl
2019-11-15 12:59:38 +01:00

54 lines
1.1 KiB
Perl

<html>
<head>
<title>form page</title>
</head>
<body>
<p>heres my test form</p>
<form method = "post" action = "/your.pl">
<p>First name:
<input name = "firstName" type = "text" size = "20"></p>
<p>Last name:
<input name = "lastName" type = "text" size = "20"></p>
<p>Phone number:
<input name = "phone" type = "text" size = "20"></p>
<p>Date (MM/DD/YY):
<input name = "date" type = "text" size = "20"></p>
<p>Time (HH:MM:SS):
<input name = "time" type = "text" size = "20"></p>
<input type = "submit" value = "submit">
<input type = "reset" value = "reset">
</form>
</body>
</html>
#your.pl
#!/usr/bin/perl
use strict;
use warnings;
use CGI ':standard';
my $firstName = param( "firstName" );
my $lastName = param( "lastName" );
my $phone = param( "phone" );
my $date = param( "date" );
my $time = param( "time" );
print header();
print start_html( -title => "form page" );
if ( $date =~ m#^(1[012]|0?[1-9])/([012]?\d|3[01])/(\d\d)$# ) {
print "<p>The date is $1 / $2 / $3.</p>";
}
print end_html();