function date_jscalendar_validate in Date 5
Validation for jscalendar input
File
- ./
date.inc, line 1097 - Date/time API functions
Code
function date_jscalendar_validate($value, $fieldname, $type, $format, $required, $granularity = array(
'M',
'D',
'Y',
)) {
$value = trim($value);
if (!$required && $value == '') {
return TRUE;
}
switch ($type) {
case DATE_UNIX:
if (!date_custom2unix($value, $format)) {
form_set_error($fieldname, t('The text \'%s\' is not a valid date.', array(
'%s' => $value,
)));
return FALSE;
}
break;
case DATE_ISO:
if (!date_custom2iso($value, $format)) {
form_set_error($fieldname, t('The text \'%s\' is not a valid date.', array(
'%s' => $value,
)));
return FALSE;
}
break;
}
return TRUE;
}