note 56425 deleted from function.ereg by tularis
| From: | tularis@php.net | Date: | Thu, 31 May 2007 13:24:08 +0000 |
| Subject: | note 56425 deleted from function.ereg by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127069@lists.php.net to get a copy of this message | ||
Note Submitter: chrismax2u at yahoo dot com dot cn
----
use ereg() and checkdate()
$input_date="2005-09-02";
//check date with ereg()
if (!ereg("^(20[0-9]{2})-(0[1-9]|1[0-2])-([12][0-9]|3[01])$",
$input_date))
{
echo "<script>alert(\"pass!\")</script>";
}
//check date with checkdate()
$explode_date=explode("-",$input_date);
if (!checkdate($explode_date['1'],$explode_date['2'],
$explode_date['0']))
{
echo "<script>alert(\"stop!\")</script>";
exit;
}