Hi,
Sorry I know this is probably a really simple question for most, but perl is not yet one of my strong points.
I have a perl script running but have now added a telephone number field to my HTML web form. This script works fine with this but it allows a user to input any character not just numbers. I already have some field checking in place for empty fields or missing chars from an email field which redirects the user onto to an error page. I'd like this to happen if any characters other than digits are input into that field. Thanks if you can help, I greatly appreciate any help....
This is a piece of the code that validates and the variable is $Telephone (it already checks that something is input)
# _________________________________________________________
sub CheckEmailAddressFormat {
if (index($Email, "@") < 1) {&DoEmailError;}
if (index($Email, ".") < 1) {&DoEmailError;}
if (index($Email, " ") > -1) {&DoEmailError;}
}
sub CheckFields {
if (!$Forename || $Forename eq ' ') {&DoEmailError;}
if (!$Email || $Email eq ' ') {&DoEmailError;}
if (!$Telephone || $Telephone eq ' ') {&DoEmailError;}
}
sub DoEmailError {
print "Location: $ErrorPage\n\n";
exit;
}
# _________________________________________________________
Sorry I know this is probably a really simple question for most, but perl is not yet one of my strong points.
I have a perl script running but have now added a telephone number field to my HTML web form. This script works fine with this but it allows a user to input any character not just numbers. I already have some field checking in place for empty fields or missing chars from an email field which redirects the user onto to an error page. I'd like this to happen if any characters other than digits are input into that field. Thanks if you can help, I greatly appreciate any help....
This is a piece of the code that validates and the variable is $Telephone (it already checks that something is input)
# _________________________________________________________
sub CheckEmailAddressFormat {
if (index($Email, "@") < 1) {&DoEmailError;}
if (index($Email, ".") < 1) {&DoEmailError;}
if (index($Email, " ") > -1) {&DoEmailError;}
}
sub CheckFields {
if (!$Forename || $Forename eq ' ') {&DoEmailError;}
if (!$Email || $Email eq ' ') {&DoEmailError;}
if (!$Telephone || $Telephone eq ' ') {&DoEmailError;}
}
sub DoEmailError {
print "Location: $ErrorPage\n\n";
exit;
}
# _________________________________________________________