note 56425 added to function.ereg
| From: | chrismax2u at yahoo dot com dot cn | Date: | Fri, 02 Sep 2005 08:15:16 +0000 |
| Subject: | note 56425 added to function.ereg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94639@lists.php.net to get a copy of this message | ||
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;
}
----
Manual Page -- http://www.php.net/manual/en/function.ereg.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56425
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56425&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56425&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56425&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56425&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56425&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56425&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56425&report=yes
Search -- http://master.php.net/manage/user-notes.php