zach4618
07-12-2007, 06:18 AM
I have a form that validates each field before it can be submitted using regular expressions. I also have an unordered list that returns different error messages based on what the regular expressions evaluate to. What I would like to do is create a different error message when a field is blank vs. when it contains invalid characters. Here is the relevant code that I have right now:
$firstNameError=0;
if (!eregi("^[[:alpha:]]+$", $firstName)) {$firstNameError=1}
What I thought I should do is create an if statement that reads:
if ($firstName=="") {create separate error message}
However that will not work since the first if statement also tests for at least one character. I could create a regular expression that tests for the presence of every character other than letters, but that seems like a ridiculous thing to do. Any help is appreciated.
$firstNameError=0;
if (!eregi("^[[:alpha:]]+$", $firstName)) {$firstNameError=1}
What I thought I should do is create an if statement that reads:
if ($firstName=="") {create separate error message}
However that will not work since the first if statement also tests for at least one character. I could create a regular expression that tests for the presence of every character other than letters, but that seems like a ridiculous thing to do. Any help is appreciated.