Để kiểm tra Email có trùng lặp hay không trước tiên chúng ta kiếm một đoạn Jquery kiểm tra Email. và đây là đoạn code:
12345678910111213141516 // First we trigger the form submit event $('.wpcf7-submit').click(function () { // We remove the error to avoid duplicate errors $('.error').remove(); // We create a variable to store our error message var errorMsg = $('<span role="alert" class="wpcf7-not-valid-tip">メールアドレスを正しく入力してください。</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 ($('.email').find('input').val() !== $('.email-confirm').find('input').val()) { errorMsg.insertAfter($('.email-confirm').find('input')); return false; } else { // If they do match we remove the error and we submit the form $('.error').remove(); return true; } });
Sau đó chúng ta để ở đâu đó và tìm đến file này controller.php
và Tìm đến: function wpcf7_enqueue_scripts() { ...} này và chèn đoạn code dưới vào:
1
2
3
4
5
|
function wpcf7_enqueue_scripts() {
.....
wp_enqueue_script( 'email_verification',
wpcf7_plugin_url( 'includes/js/email_verification.js' ),
array( 'jquery', 'jquery-form' ), WPCF7_VERSION, $in_footer );
......
}
|
Vậy là xong.
Tác Giả : Hạnh Đô
0 nhận xét: