Home Forums Weaver and Plugin Interaction Unable to send email from contact form

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #52578
    davidflin
    Participant

    https://dutchphototrek.com

    I have a ‘contact’ form, where a visitor fills in 4 fields:

    email address, confirm email address, subject, message

    Then clicks a ‘submit’ button.

    The fields are validated by the following jQuery code:

    $(“form”).submit(function (e) {

    e.preventDefault(); // delays form submission while

    // lines field validation code are executed

    if (error != “”) {

    $(“#errorMsg”).html(‘

    There were error(s) in your form:

    ‘+ error + ‘

    ‘);

    } else {

    $(‘form’).unbind(‘submit’); $(‘#submit’).click();  // submit form if there are no errors

    }

    });

    If the email address is invalid, or any of the fields are empty, and error message is correctly displayed.

    If no error is generated, then the code fails to submit the form and send the email. Instead a new form is generated with the title” Search Results for:””

    If I change the theme to Twenty Seventeen, then the form is submitted and the email is sent correctly using the following php code:

    mail($emailTo, $subject, $content, $headers);

    I am using:

    Wordpress 4.9.1

    Akeeba Backup 2.4.0

    Google Analytics… 6.2.6

    Insert PHP 1.3

    jQuery in Posts, Pages… 4.0

    Metaslider 3.6.7

    Simple Custom CSS 3.3

    Weaver Show Posts 1.3.9

    Weaver Xtreme Plus 3.1.1

    Weaver Xtreme Theme Support 3.1.9

    WP Mail SMTP 1.1.0

    YOAST SEO 5.9.3

    #52579
    Weaver
    Keymaster

    We really can’t support custom JavaScript using other plugins.

    The only thing I can see to ask is : Where is the submit being handled? That usually requires adding very specific code to your site that will look for and process submits from forms.

    It seems to me that the submit button ends up generating an empty search string and invokes to search form.

    This has nothing to do with the theme, but everything to do with what you may have installed to handle the submit button. These details are usually handled by plugins – such as form plugins.

    #52582
    scrambler
    Moderator

    A good forum for javascript question is stackoverflow

    https://stackoverflow.com/

     

    #52583
    Gillian
    Moderator

    For such a simple form, rather than using custom JavaScript why not use a popular and well-supported form plugin? For example, Contact Form 7 (which also provides spam filtering and other useful features).

    #52588
    davidflin
    Participant

    Thanks for your reply.

    The line of jQuery that is failing is:

    $(‘form’).unbind(‘submit’); $(‘#submit’).click();

    I use jQuery extensively, and have no problem with any other code

    The reason U posted here, and not Stackoverflow is that the above code works as it is supposed to with all other  themes; it only fails with Weaver Extreme Plus.

    But thank you once again for taking the trouble for looking at this.

    #52596
    Weaver
    Keymaster

    I can’t see all your code, but perhaps use ‘jQuery’ instead of ‘$’?

    #52598
    scrambler
    Moderator

    yes jQuery instead of $ is most likely the culprit, I had the same issue when I started playing with jQuery 🙂

    You may want to read

    Scripts: Advanced styling or design changes

     

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘ Weaver and Plugin Interaction’ is closed to new topics and replies.