Skip to content
tirumal edited this page Apr 11, 2013 · 4 revisions

Contact form 7 custom validation is a extension to basic cf7 validation rules. It was built upon the basic requirement of validation required for any form. However, you can also make your own validation rules.

Following contact form 7 hooks are used to add the validation filters.

For Text field validation

//add filter for text field validation
add_filter('wpcf7_validate_text','cf7_custom_form_validation', 10, 2); // text field
add_filter('wpcf7_validate_text*', 'cf7_custom_form_validation', 10, 2); // Req. text field

For textarea validation

//add fiter for text area validation\n
add_filter( 'wpcf7_validate_textarea', 'cf7_custom_textarea_validation', 10, 2 );
add_filter( 'wpcf7_validate_textarea*', 'cf7_custom_textarea_validation', 10, 2 );

Click here for code explanation

Clone this wiki locally