Sea*_*ung 7 php wordpress wordpress-plugin contact-form-7
我使用Contact Form 7 Wordpress插件将联系表单添加到网站.表单需要为用户的电子邮件地址设置第二个字段,并将其与第一个字段进行比较以捕获任何拼写错误.这是联系和登记表格中非常常见的要素.
是否有可用于实现此类功能的Contact Form 7标记?如果没有,任何修改过这个插件的人都可以指出我的解决方案吗?
小智 5
看看这个:http : //wordpress.org/plugins/checkmail-validation-for-contact-form-7/
根据他们:
Checkmail Validation for Contact Form 7 将复查电子邮件字段添加到您的表单并验证电子邮件与 CF7 Ajax 验证的匹配。
双重电子邮件检查 此插件在联系表格 7 中添加了一个名为“Checkmail”的新字段,允许在提交表单时进行双重电子邮件检查。新字段将要求用户通过将其输入到第二个字段中来确认他们的电子邮件。
如果您想在您的表单中执行此操作,您只需在 CF7 表单中添加“Checkmail”字段并输入您要检查的电子邮件字段名称。验证是由 CF7 Ajax 驱动的风格完成的:提交表单时 CF7 将进行双重电子邮件检查,如果不匹配则返回错误并要求用户验证电子邮件地址。
小智 5
我正在搜索这个并让它以其他方式为我工作。在联系表单 7 字段上制作如下两个字段..
[email* email placeholder "Email"]
[email* email-confirm placeholder "Confirm Email"]
Run Code Online (Sandbox Code Playgroud)
将以下 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' );
Run Code Online (Sandbox Code Playgroud)
确保更改文件路径以匹配并将包含以下代码的 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;
}
});
} );
Run Code Online (Sandbox Code Playgroud)
我已经在我的网站上使用它并且工作正常。希望这可以帮助像我这样的人。
参考:联系表 7 验证电子邮件
| 归档时间: |
|
| 查看次数: |
13729 次 |
| 最近记录: |