Forums

Date validation

lindic 17 Feb, 2011
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:

<?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
GreyHead 17 Feb, 2011
Hi lindic,

Is this ChronoForms v4? If so, then I've no idea.

There's a fix for ChronoForms v3.2 here

Bob
lindic 17 Feb, 2011
Hi Bob,
yes it is v4. Maybe I should switch to v3 to get it work... but I like v4.
GreyHead 17 Feb, 2011
Hi lindic,

Max is using the FormCheck library it doesn't seem to have a date validation built in and while there is a custom validation the info is a bit thin :-(

Bob
This topic is locked and no more replies can be posted.