I was using wpcf7_validate_text for all input type text as a custom validation in function.php, however after updating the form i could not see the my custom validation on input type text and textarea.
Can you please help how can i update those again. Code is given below
/* Code in Function.php */
add_filter( 'wpcf7_validate_text', 'custom_firstname_confirmation_validation_filter', 5, 2 );
add_filter( 'wpcf7_validate_text*',
'custom_firstname_confirmation_validation_filter', 5, 2 );
function custom_firstname_confirmation_validation_filter( $result, $tag ) {
if ( 'firstname' == $tag->name ) {
$firstname = isset( $_POST['firstname'] ) ? trim( $_POST['firstname'] ) : '';
if(empty($firstname)) {
$msg = 'first name is Required';
$result->invalidate( $tag, $msg);
}
else if (strlen((string)$firstname) < 6 || strlen((string)$firstname) > 12) {
$msg = 'first name is not valid';
$result->invalidate( $tag, $msg);
}
}
return $result;
}
<p>*All fields are required</p>
[response]
[select* inquiry "Business Enquiry" "Media Enquiry" ]
[phonetext phone ]
[text* phonenum class:phonenum placeholder "Phone number" ]
[select* title "Mr" "Ms" "Mrs"]
[email* email placeholder "Email" ]
[text* firstname placeholder "First Name" ]
[text* lastname placeholder "Last Name" ]
[textarea textarea-854 placeholder "Enter your message here"]
[checkbox checkbox-57 checked id:chk1 "" ]
[acceptance acceptance624 id:iagree ]
[submit class:btn-theme class:btn-submit "Enquire"]