Home › Forums › Weaver and Plugin Interaction › Unable to send email from contact form
- This topic has 6 replies, 4 voices, and was last updated 5 years, 5 months ago by
scrambler.
-
AuthorPosts
-
December 19, 2017 at 19:28 UTC - Views: 44 #52578
davidflin
ParticipantI 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
December 19, 2017 at 21:23 UTC - Views: 41 #52579Weaver
KeymasterWe 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.
December 19, 2017 at 21:49 UTC - Views: 32 #52582scrambler
ModeratorDecember 19, 2017 at 22:34 UTC - Views: 31 #52583Gillian
ModeratorFor 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).
December 20, 2017 at 06:36 UTC - Views: 21 #52588davidflin
ParticipantThanks 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.
December 20, 2017 at 16:54 UTC - Views: 10 #52596Weaver
KeymasterI can’t see all your code, but perhaps use ‘jQuery’ instead of ‘$’?
December 20, 2017 at 18:41 UTC - Views: 6 #52598scrambler
Moderatoryes jQuery instead of $ is most likely the culprit, I had the same issue when I started playing with jQuery 🙂
You may want to read
-
AuthorPosts
- The forum ‘ Weaver and Plugin Interaction’ is closed to new topics and replies.