The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
untitled PHP Code
Posted by: noir_lord | October 17, 2010 @ 7:50am
PHP Code
[
Download
]
class DateValidator extends CustomValidator { private $form_element; public function __construct($form_element) { $this->form_element = $form_element; } function DoValidate(&$formars, &$error_hash) { $date = $formars[$this->form_element]; //check that input conforms to basic structure if (!preg_match('/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/', $date)) { $error_hash[$this->form_element] = "Date Invalid - Format is day/month/year for example 1/1/2010 or 26/09/2011"; return false; } // break the date into a list and use checkdate to confirm the date is a valid real date list( $d, $m, $y ) = preg_split('/[-\.\/ ]/', $date); if (checkdate($m, $d, $y)) { return true; } else { $error_hash[$this->form_element] = "That date does not exist, Format is day/month/year for example 1/1/2010 or 26/09/2011"; return false; } } }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.51 / 8
49 Votes
http://codebin.yi.org/898
page generated in 0.01 seconds