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..