Contact Form 7
[resolved] wpcf7_validate_text is working but 'reason' text is coming blank. (2 posts)

  1. tonyparera
    Posted 4 years ago #


    I have added this filter on wpcf7_validate_text, It works well but unable to show any text, it shows just blank text box next to the field and result-box with standard validation error.

    // Add custom validation for CF7 form fields
    function custom_text_validation_filter($result,$tag){
    	$type = $tag['type'];
    	$name = $tag['name'];
    	if($name == 'page_url'){ // Only apply to fields with the form field name of "page_url"
    		$the_value = $_POST[$name];
    		if($the_value !== 'www.google.com'){ // Sample test.
    			$result['valid'] = false;
    			$result['reason'][$name] = 'This facebook page doesn\'t exist.';
    	return $result;
    add_filter( 'wpcf7_validate_text', 'custom_text_validation_filter', 10, 2 ); // text field
    add_filter( 'wpcf7_validate_text*', 'custom_text_validation_filter', 10, 2 ); //Req. text field.


  2. tonyparera
    Posted 4 years ago #


    Just to update, It's my mistake.

    Actually it was working as expected, the only issue was that text and background color was same so I couldn't see the text.

    Changed text color and issue resolved.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Contact Form 7
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.