本文整理汇总了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