Hi,
I need a simple date validation for a text field and don't know, how to do this. I don't want to use the datepicker, because it is the date of birth and I think, most users don't know how to choose the year with a few clicks. So I want them to write in a textbook.
I read a lot of posts here and tried out a lot, but nothing really works. The last solution was this simple script, that I pasted in the OnSubmit box:
But after the submit a got a blank page.
How can I validate a date like mm/dd/YYYY? It would be nice, if it validates in PHP and Javascript, but if PHP only works, it is ok for me.
Thanks in advance,
Stephan
I need a simple date validation for a text field and don't know, how to do this. I don't want to use the datepicker, because it is the date of birth and I think, most users don't know how to choose the year with a few clicks. So I want them to write in a textbook.
I read a lot of posts here and tried out a lot, but nothing really works. The last solution was this simple script, that I pasted in the OnSubmit box:
<?php
$date = new DateTime(JRequest::getVar('dateofbirth', '', 'dateofbirth'));
$d = explode("/", $date);
if (!checkdate($d[0], $d[1], $d[2])) {
return '- Wrong date format!<br />';
}
?>
But after the submit a got a blank page.
How can I validate a date like mm/dd/YYYY? It would be nice, if it validates in PHP and Javascript, but if PHP only works, it is ok for me.
Thanks in advance,
Stephan