and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
So here's my php function:
function valDate($date)
{
$valid = true;
echo "In Date = ".$date."<br />";
//if (!eregi("([1-9]|(0[1-9])|([1-2][0-9])|3[0-1])\/((0[1-9])|(1[0-2]))\/[0-9]{1,4}$", $date))
if(!eregi("\d{2}\/\d{2}\/\d{4}", $date))
{
$valid = false;
echo "valid after = ".$valid."<br/>";
}
return $valid;
}
The problem is that this function always returns false. I only want it to return false if a date is NOT found. I know it must be something simple. Any help would be much appreciated. Also note that I commented out the line I wanted to use and used a less complicated regex so I could debug. Thanks again.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Okay, so I tried your code modifying my function to be:
if (!valDate($burialDeathDate))
{
echo "got to burialDeathDate<br/>";
$isValid = false;
}
So if valDate finds the pattern it returns true which is negated to false preventing it from entereing the conditional. I don't know why it's not working. any ideas?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Since you're not using $matches in your code, you could just leave it out and call preg_match() with just two parameters, which is faster. However maybe you could use them and drop the explode() part.