WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. tonyparera
    Member
    Posted 2 years ago #

    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/

  2. tonyparera
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.