I am trying to validate duplicate email using jquery Validate plugin in wordpress.But for some reason the function returns 0 always.

jQuery code:

 email: {
           required: true,
           email: true,
                      url: CartAjax.ajaxurl,
                      type: "post",
                            email: function()
                             return $('#frmorder :input[name="email"]').val();
                             action: 'duplicate_email_check'

In my theme functions.php

add_action('admin_post_duplicate_email_check', 'duplicate_email_check');
add_action('admin_post_nopriv_duplicate_email_check', 'duplicate_email_check');

function duplicate_email_check()
    echo "true";

If true it should return 1 instead 0 but it’s returning 0 always.

Any help is highly appreciated.

Read more here: Duplicate email validation using jquery validate in wordpress


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: