如何在wordpress联系表单7中显示自定义错误消息。?

In wordpress contact form 7, i want to show different error messages for sender must fill in field like "Your name is required", "Your email is required" instead of common message Please fill the required field. for all the fields in my form,

please share here, if you have any idea.

Thanks in advance.

At the bottom of the contact form page there are a heap of settings where you can adjust which error messages are displayed in different situations.

However, I think if you wanted to show specific messages for a field that have not been filled in, you would need to dequeue the contact form 7 javascript and create your own.

wp_deregister_script( 'contact-form-7' ); 

Then I'd recommend copying the script into your theme, enqueing it through functions.php and adding the necessary javascript to target your specific inputs.

Call display: none css to your other error messages and keep only one common message

Write following code in your themes's css file

span.wpcf7-not-valid-tip{

display:none; }

you can use jquery validation. You can easly implement jquery validation in contact form 7

here is sample code for jquery validation.

 $(".wpcf7-form").validate({
        rules: {
           yourname: "required",
         youremail: {
           required: true,
           email: true
          },
        },
           messages: {
            yourname: "Please include your name.",
            youremail: "Please include a valid email address.",
            yourmessage: "Please tell me how I can help you.",

        },
    });

PHP code,Link contact form 7

add_filter( 'wpcf7_validate_email*', 'custom_email_confirmation_validation_filter', 20, 2 );

function custom_email_confirmation_validation_filter( $result, $tag ) {
if ( 'your-email-confirm' == $tag->name ) {
    $your_email = isset( $_POST['your-email'] ) ? trim( $_POST['your-email'] ) : '';
    $your_email_confirm = isset( $_POST['your-email-confirm'] ) ? trim( $_POST['your-email-confirm'] ) : '';

    if ( $your_email != $your_email_confirm ) {
        $result->invalidate( $tag, "Are you sure this is the correct address?" );
    }
}

return $result;
}

Hope this will helps you.