Forum Moderators: coopster
After many searches, it would seem that most threads are about returning errors if a field is left blank - but I have no difficulty doing that. The problem arises when I want a user to have the option of leaving fields blank. This is what we are looking at:
if (!preg_match("/^([0-9])+$/",$icq)) {
$invalidIcq = 1;
header("Location: example.php?invalidIcq=1");
}
elseif (!preg_match("/^([a-z0-9])+$/",$aim)) {
$invalidAim = 1;
header("Location: example.php?invalidAim=1");
}
else
{
Do something
}
Now, a user might have an ICQ number but not an AIM ID, so they may wish to enter one or the other. But if one of the fields is left blank the invalid error is returned. I think this is happening because the code is checking against the preg_match function and an empty field is not a character in the regex. I'm completely baffled by this; any ideas on how to allow a user to leave a field blank while still performing a preg_match function?
Thank you,
Max