how to validate a valid email in html contact form using javascript code code example
Example: validate email function
sub Validate_Email($)
{
my $sEmail = $_[0];
my $sRetMsg = "";
my $sUserNmRegex = "^[[:alnum:]]+([.!#\$\%&'*+-\/=?^_'{|]?[[:alnum:]]+)*";
my $sDomainRegex = "@[[:alnum:]]+([.-]{1}[[:alnum:]]+)*";
my $sEndRegex = "([.]{1}[[:alnum:]]+)+";
if ($sEmail =~ /$sUserNmRegex$sDomainRegex$sEndRegex$/) {
$sRetMsg = "Email is valid";
}
else {
$sRetMsg = "Email is not valid";
}
return $sRetMsg;
}
my $sEmail = '[email protected]';
print "[Email:$sEmail] : " . Validate_Email($sEmail) . "\n";