最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

customization - Contact From 7 Custom Validation Issues

programmeradmin3浏览0评论

Here is the situation: I have to make a textarea a required field when the user selects "Other" in a dropdown. That does work, however whenever I try to chec if the validation on all other fields BEFORE works... well it doesn't .. It doesn't say the user should fill it up, although its mostly required fields. It does work when I add remove_filter("blabla", "blabla", 10, 2); but then the custom validation does not work. I hope you guys have an idea where this might be coming from ... that's my code

add_filter("wpcf7_validate_textarea", 'custom_text_validation_filter', 10, 2);
function custom_text_validation_filter ( $result, $tag )
{
    $result = new WPCF7_Validation();

    if ( $tag->name != "comment" )
    {
        return $result;
    }
    else
    {
        $reclReason = isset( $_POST['reason']) ? $_POST['reason'] : ' ';
        $comment = isset($_POST['comment']) ? $_POST['comment'] : ' ';

        if ( $reclReason == 'Other*' && $comment == '' )
        {
            $result->invalidate($tag->name, "Please fill in the required field!");
        }
        else
        {
            $result['valid'] = true;
        }
    }
    return $result;
}

also without the else at the end (making the field valid otherwise) it also doesn't work, it says it's invalid although there has been something written in..

发布评论

评论列表(0)

  1. 暂无评论