php - 如何在 wordpress 联系表 7. 中显示自定义错误消息?

标签 php wordpress contact-form

在 wordpress contact form 7 中,我想为 sender must fill in 字段显示不同的错误消息,例如“您的姓名是必需的”,“您的电子邮件是必需的”而不是普通消息请填写必填字段。对于我表单中的所有字段,

如果您有任何想法,请在这里分享。

提前致谢。

最佳答案

您可以使用 jquery 验证。您可以在联系表 7 中轻松实现 jquery 验证

这里是 jquery 验证的示例代码。

 $(".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 - 如何在 wordpress 联系表 7. 中显示自定义错误消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23425937/

相关文章:

php - 带回调的 JSONP 和 GET - 需要帮助纠正错误

php - ubuntu 20.04 apache2 - php 文件下载

wordpress - 验证 WordPress REST API JWT token 时出现 jwt_auth_no_auth_header 错误

jQuery css 宽度在 IE/Opera/FF 中不起作用,但在 Chrome 中起作用

html - 提交表单按钮

php - Braintree PHP 库 (3.8.0) 错误处理

php - .htaccess 多域重写

javascript - Ajax 调用在移动设备中返回 0 作为响应

php - 提交操作后自动向下滚动

php代码显示页面上的显示而不是联系表单