本文整理匯總了PHP中GFFormDisplay::checkdate方法的典型用法代碼示例。如果您正苦於以下問題:PHP GFFormDisplay::checkdate方法的具體用法?PHP GFFormDisplay::checkdate怎麽用?PHP GFFormDisplay::checkdate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GFFormDisplay
的用法示例。
在下文中一共展示了GFFormDisplay::checkdate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validate
//.........這裏部分代碼省略.........
if ($requires_valid_number && !$is_valid_number) {
$field["failed_validation"] = true;
$field["validation_message"] = empty($field["errorMessage"]) ? GFCommon::get_range_message($field) : $field["errorMessage"];
} else {
if ($field['type'] == 'quantity') {
if (intval($value) != $value) {
$field['failed_validation'] = true;
$field['validation_message'] = empty($field['errorMessage']) ? __('Please enter a valid quantity. Quantity cannot contain decimals.', 'gravityforms') : $field['errorMessage'];
} else {
if (!empty($value) && (!is_numeric($value) || intval($value) != floatval($value) || intval($value) < 0)) {
$field['failed_validation'] = true;
$field['validation_message'] = empty($field['errorMessage']) ? __('Please enter a valid quantity', 'gravityforms') : $field['errorMessage'];
}
}
}
}
break;
case "phone":
$regex = '/^\\D?(\\d{3})\\D?\\D?(\\d{3})\\D?(\\d{4})$/';
if ($field["phoneFormat"] == "standard" && $value !== "" && $value !== 0 && !preg_match($regex, $value)) {
$field["failed_validation"] = true;
if (!empty($field["errorMessage"])) {
$field["validation_message"] = $field["errorMessage"];
}
}
break;
case "date":
if (is_array($value) && rgempty(0, $value) && rgempty(1, $value) && rgempty(2, $value)) {
$value = null;
}
if (!empty($value)) {
$format = empty($field["dateFormat"]) ? "mdy" : $field["dateFormat"];
$date = GFCommon::parse_date($value, $format);
if (empty($date) || !GFFormDisplay::checkdate($date["month"], $date["day"], $date["year"])) {
$field["failed_validation"] = true;
$format_name = "";
switch ($format) {
case "mdy":
$format_name = "mm/dd/yyyy";
break;
case "dmy":
$format_name = "dd/mm/yyyy";
break;
case "dmy_dash":
$format_name = "dd-mm-yyyy";
break;
case "dmy_dot":
$format_name = "dd.mm.yyyy";
break;
case "ymd_slash":
$format_name = "yyyy/mm/dd";
break;
case "ymd_dash":
$format_name = "yyyy-mm-dd";
break;
case "ymd_dot":
$format_name = "yyyy.mm.dd";
break;
}
$message = $field["dateType"] == "datepicker" ? sprintf(__("Please enter a valid date in the format (%s).", "gravityforms"), $format_name) : __("Please enter a valid date.", "gravityforms");
$field["validation_message"] = empty($field["errorMessage"]) ? $message : $field["errorMessage"];
}
}
break;
case "time":
//create variable values if time came in one field