【问题标题】:Contact Form 7: Is there a 'Confirm E-mail' input type?联系表 7:是否有“确认电子邮件”输入类型?
【发布时间】:2011-09-09 11:13:00
【问题描述】:

我正在使用 Contact Form 7 Wordpress 插件向网站添加联系表单。该表单需要为用户的电子邮件地址提供第二个字段,该字段与第一个字段的内容进行比较以捕获任何拼写错误。这是联系方式和注册表单中非常常见的元素。

是否有可用于实现此类功能的 Contact Form 7 标签?如果没有,任何修改过插件的人都可以为我指明解决方案的方向吗?

【问题讨论】:

  • 尝试添加两个电子邮件输入,然后在页脚中写一个小脚本以检查它们是否相同。

标签: php wordpress contact-form-7


【解决方案1】:

插件现在有一个官方教程:

http://contactform7.com/2015/03/28/custom-validation/

【讨论】:

    【解决方案2】:

    看看这个:http://wordpress.org/plugins/checkmail-validation-for-contact-form-7/

    据他们说:

    Checkmail Validation for Contact Form 7 将仔细检查电子邮件字段添加到您的表单中,并使用 CF7 Ajax 验证验证电子邮件匹配。

    双重电子邮件检查 该插件在 Contact Form 7 中添加了一个名为“Checkmail”的新字段,允许在提交表单时进行双重电子邮件检查。新字段将要求用户通过在第二个字段中输入电子邮件来确认他们的电子邮件。

    如果您想在表单中执行此操作,您只需将“Checkmail”字段添加到 CF7 表单中并输入您要检查的电子邮件字段名称。验证由 CF7 Ajax 驱动的样式完成:提交表单时,CF7 将进行双重电子邮件检查,如果不匹配则返回错误并要求用户验证电子邮件地址。

    【讨论】:

      【解决方案3】:

      我正在搜索这个并让它以其他方式对我来说很好。 在联系表单 7 字段上创建两个字段,如下所示..

      [email* email placeholder "Email"]
      [email* email-confirm placeholder "Confirm Email"]
      

      将以下 php 代码复制/粘贴到您的 functions.php 文件中

      function register_scripts() {
        if ( !is_admin() ) {
          // include your script
          wp_enqueue_script( 'email-confirm', get_bloginfo( 'template_url' ) . '/js/email-confirm.js' );
        }
      }
      add_action( 'wp_enqueue_scripts', 'register_scripts' );
      

      确保更改文件路径以匹配并将具有以下代码的js文件上传到该路径目录。

          // First we trigger the form submit event
      jQuery( document ).ready( function () {
          jQuery('.wpcf7-submit').click(function () {
              // We remove the error to avoid duplicate errors
              jQuery('.error').remove();
              // We create a variable to store our error message
              var errorMsg = jQuery('<span class="error">Your emails do not match.</span>');
              // Then we check our values to see if they match
              // If they do not match we display the error and we do not allow form to submit
              if (jQuery('.email').find('input').val() !== jQuery('.email-confirm').find('input').val()) {
                  errorMsg.insertAfter(jQuery('.email-confirm').find('input'));
                  return false;
              } else {
              // If they do match we remove the error and we submit the form
                  jQuery('.error').remove();
                  return true;
              }
          });
      } );
      

      我已经在我的网站中使用它并且工作正常。希望这可以帮助像我这样的人。

      参考:Contact Form 7 Verify Email

      【讨论】:

        猜你喜欢
        • 2014-07-09
        • 1970-01-01
        • 2021-10-06
        • 2015-10-11
        • 1970-01-01
        • 1970-01-01
        • 2022-10-23
        • 2015-05-10
        • 2015-09-16
        相关资源
        最近更新 更多