function wpcf7_number_validation_filter($result, $tag) { $tag = new WPCF7_Shortcode($tag); $name = $tag->name; $value = isset($_POST[$name]) ? trim(strtr((string) $_POST[$name], "\n", " ")) : ''; $min = $tag->get_option('min', 'signed_int', true); $max = $tag->get_option('max', 'signed_int', true); if ($tag->is_required() && '' == $value) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('invalid_required'); } elseif ('' != $value && !wpcf7_is_number($value)) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('invalid_number'); } elseif ('' != $value && '' != $min && (double) $value < (double) $min) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('number_too_small'); } elseif ('' != $value && '' != $max && (double) $max < (double) $value) { $result['valid'] = false; $result['reason'][$name] = wpcf7_get_message('number_too_large'); } if (isset($result['reason'][$name]) && ($id = $tag->get_id_option())) { $result['idref'][$name] = $id; } return $result; }
function wpcf7_number_validation_filter($result, $tag) { $tag = new WPCF7_FormTag($tag); $name = $tag->name; $value = isset($_POST[$name]) ? trim(strtr((string) $_POST[$name], "\n", " ")) : ''; $min = $tag->get_option('min', 'signed_int', true); $max = $tag->get_option('max', 'signed_int', true); if ($tag->is_required() && '' == $value) { $result->invalidate($tag, wpcf7_get_message('invalid_required')); } elseif ('' != $value && !wpcf7_is_number($value)) { $result->invalidate($tag, wpcf7_get_message('invalid_number')); } elseif ('' != $value && '' != $min && (double) $value < (double) $min) { $result->invalidate($tag, wpcf7_get_message('number_too_small')); } elseif ('' != $value && '' != $max && (double) $max < (double) $value) { $result->invalidate($tag, wpcf7_get_message('number_too_large')); } return $result; }