Question: first of all I'm using latest WordPress and CF7 version. I want to include the minlength validation for the tel field before. I know the syntax `minlength=""`
can be used inside the CF7, but for unknown reason, it won't work. Only `maxlength=""` is ok.

I already contacted the plugin support, but seems like no further response. So, I search here and found some code and I edit it so that the field will return an error if user put less than 10 characters. I put the codes inside functions.php

```
function custom_phone_validation($result,$tag){
   $type = $tag['type'];
   $name = $tag['name'];
   if($name == 'Subject'){
       $phoneNumber = isset( $_POST['phonenumber'] ) ? trim( $_POST['phonenumber'] ) : '';
       if($phoneNumber < "9"){
           $result->invalidate( $tag, "phone number is less" );
       }
   }
   return $result;
   }
   add_filter('wpcf7_validate_tel','custom_phone_validation', 10, 2);
   add_filter('wpcf7_validate_tel*', 'custom_phone_validation', 10, 2);

```

The result now is, it always display the "phone number is less" even though I insert more than 9 characters. **May I know what wrong and how to solve it?**

Answer: 
as I've tested you must have your `tel` field `[tel* phonenumber tel-503]` where `phonenumber` is name of postfield you are posting, second issue in your code is `$name=='Subject'` as you are validating `tel` so `$name` will be `phonenumber`. So it will be like this:

```
function custom_phone_validation($result,$tag){
   $type = $tag['type'];
   $name = $tag['name'];
   if($name == 'phonenumber'){
   $phoneNumber = isset( $_POST['phonenumber'] ) ? trim( $_POST['phonenumber'] ) : '';
   if(strlen($phoneNumber) < 9){
       $result->invalidate( $tag, "phone number is less" );
   }
  }
  return $result;
  }
add_filter('wpcf7_validate_tel','custom_phone_validation', 10, 2);
add_filter('wpcf7_validate_tel*', 'custom_phone_validation', 10, 2);

```
Your `$phoneNumber` is a string. You will need to get the length of the string to compare with 9.

Your code will become:

```
function custom_phone_validation($result,$tag){
    $type = $tag['type'];
    $name = $tag['name'];
    if($name == 'Subject'){
        $phoneNumber = isset( $_POST['phonenumber'] ) ? trim( $_POST['phonenumber'] ) : '';
        if(strlen($phoneNumber) < 9){//<=====check here
            $result->invalidate( $tag, "phone number is less" );
        }
    }
    return $result;
}
add_filter('wpcf7_validate_tel','custom_phone_validation', 10, 2);
add_filter('wpcf7_validate_tel*', 'custom_phone_validation', 10, 2);

```