首页 文章

联系表格7:是否有'Confirm E-mail'输入类型?

提问于
浏览
6

我使用Contact Form 7 Wordpress插件将联系表单添加到网站 . 表单需要为用户的电子邮件地址设置第二个字段,并将其与第一个字段进行比较以捕获任何拼写错误 . 这是联系和登记表格中非常常见的要素 .

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

3 回答

  • 3

    检查一下:http://wordpress.org/plugins/checkmail-validation-for-contact-form-7/

    根据他们:

    Checkmail Validation for Contact Form 7 add the double check email field to your form and verify email match with the CF7 Ajax validation.

    双重电子邮件检查此插件在联系表单7中添加一个名为"Checkmail"的新字段,允许在提交表单时进行双重电子邮件检查 . 新字段将要求用户通过在第二个字段中键入来确认其电子邮件 .

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

  • 4

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

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

  • 4

    我正在搜索这个,并让它以其他方式对我很好 . 在联系表格-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

相关问题