如何验证复选框以仅在wordpress联系表单7中选择一个?我在functions.php
中编写了以下代码function custom_cf7_required_check_filter($result, $tag) {
$val = $_POST['Yes'];
$opts = strpos($val, ",");
if($opts != false){
$result['reason']['Yes'] = "True";
}else{
$result['reason']['Yes'] = "False";
}
return $result;
}
add_filter('wpcf7_validate_checkbox', 'custom_cf7_required_check_filter', 10, 2);
答案 0 :(得分:0)
为什么不使用联系表单7内置验证?根据需要设置......
[checkbox* checkbox-71 "YES"]