Contact Form 7 Text Field Validation


Contact Form 7 Text Field Validation

Contact Form 7 text field validation filter hooks details. We can modify the validation function by wpcf7_validate_text filter.

The wpcs_custom_validation_filter hook will run during submission time. The $result is WPCF7_Validation object. It has invalidate method. The invalidate method will store invalid fields when we call invalidate method.

Best contact form 7 database plugin. Get it for free!

The wpcf7_validate_text Filter

The Contact Form 7 text field validation filter hook example. This example will check exists number in text fields. This code returns an error message Sorry… Number exists.. if a number exists in text fields.

Best contact form 7 addons. Get it now

How to Change Custom Error Message From WP-Admin?

We need to hook wpcf7_messages by filter hooks.

Add $result->invalidate( $tag, wpcf7_get_message( 'invalid_wpcs_custom_error' ) ); in wpcs_custom_validation_filter function. Then go to wp-admin > contact form 7 > messages.

Contact form 7 custom error messages
Contact form 7 custom error messages

How to Save Data to MySQL Database?

We can save submission data by CFDB7 or CF7ADB plugin.

We can save the submission to a separate table and column automatically by the CF7ADB plugin.

Custom Plugin Development

Feel free to PM https://ciphercoin.com/service