Contact Form 7 – Tel Field Validation

Google (G Suite) Email Accounts not receiving Website Forms Auto Responder
February 26, 2020
PHP Form/mail()/phpmailer Issue – Godaddy Hosting
March 7, 2021

Contact Form 7 – Tel Field Validation

Add below code in functions.php file for Validation of Phone number (10 Digits only)

Step 1: Go to your CF7 (Contact form 7) Plugin and add tel tag
Step 2: After assigning tel tag add below code in functions.php file
Step 3: Fill the form and check once, it should display Validation error for Telephone field
Note: This is applicable for all the Contact form 7 Versions.

// define the wpcf7_is_tel callback 
function custom_filter_wpcf7_is_tel( $result, $tel ) { 
  $result = preg_match( '/^\(?\+?([0-9]{1,4})?\)?[-\. ]?(\d{10})$/', $tel );
  return $result; 
}

add_filter( 'wpcf7_is_tel', 'custom_filter_wpcf7_is_tel', 10, 2 );

Leave a Reply

Your email address will not be published. Required fields are marked *