Support » Plugins and Hacks » Contact Form 7 » [Plugin: Contact Form 7] wpcf7_validate_text is working but 'reason' text is coming blank.

  • Resolved tonyparera

    (@tonyparera)


    Hi,

    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.

    http://wordpress.org/extend/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
  • Hi,

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Contact Form 7] wpcf7_validate_text is working but 'reason' text is coming blank.’ is closed to new replies.