我想使用gform_field_validation
验证字段我发现this documentation
但没那么有用
add_filter("gform_field_validation", "custom_validation", 10, 4);
function custom_validation($result, $value, $form, $field){
$number = GFCommon::to_number($value,"");
if (($field["id"] == 1) && ($field["id"] == 1))
if( ($result["is_valid"]) && ($number >= 1000) && ($number <= 1999)){
$result["is_valid"] = false;
$result["message"] = "INCORRECT NUMBER";
}
return $result;
}
任何建议都将受到赞赏
答案 0 :(得分:0)
@GDB非常感谢,我在这里找到了解决方案
add_filter("gform_field_validation", "custom_validation", 10, 4);
function custom_validation($result, $value, $form, $field){
if (($field["id"] == 1) && ($field["id"] == 1))
if( ((intval($value) > 999) || (intval($value) < 2000)){
$result["is_valid"] = false;
$result["message"] = "INCORRECT NUMBER";
}
return $result;
}