Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ccurtin/3c31593c5e45fc67b35d to your computer and use it in GitHub Desktop.
Save ccurtin/3c31593c5e45fc67b35d to your computer and use it in GitHub Desktop.
:Wordpress: :Plugins: :Newsletters: simple form setup
<script type="text/javascript">
//<![CDATA[
if (typeof newsletter_check !== "function") {
window.newsletter_check = function (f) {
var re = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-]{1,})+\.)+([a-zA-Z0-9]{2,})+$/;
if (!re.test(f.elements["ne"].value)) {
alert("Please Enter a valid email");
return false;
}
if (f.elements["nn"] && (f.elements["nn"].value == "" || f.elements["nn"].value == f.elements["nn"].defaultValue)) {
alert("Please enter a valid name");
return false;
}
if (f.elements["ny"] && !f.elements["ny"].checked) {
alert("You must accept the privacy statement");
return false;
}
return true;
}
function subscribe()
{
var form = document.getElementById("subscribe_form");
form.submit();
}
}
//]]>
</script>
<div class="newsletter newsletter-subscription">
<form method="post" id="subscribe_form" action="http://localhost:8081/hub/wordpress/wp-content/plugins/newsletter/do/subscribe.php" onsubmit="return newsletter_check(this)">
<!-- first name -->
<div class="form-row">
<input class="newsletter-firstname" type="text" name="nn" size="40" aria-required="true" placeholder="Name" required>
</div>
<!-- email -->
<div class="form-row">
<input class="newsletter-email" type="email" name="ne" size="40" aria-required="true" placeholder="Email" required>
</div>
<div class="module-button-row group">
<a style="font-size:100%; height:auto;" class="button group lightbrown small text-size-100% text-weight-thick" onclick="subscribe();">
SUBSCRIBE
<i class="fa fa-arrow-circle-right"></i></a>
</div>
</form>
</div>

HTML Snippet to be used with Wordpress 'Newsletters' plugin

  1. go to Admin_Menu->Newsletters->Subscription_Forms->Alternative_Forms {Enter the code below into a form box}
  2. Insert Newsletter module into a widget and enter {subscription_form_x} where x is the number of the alternative form box you entered the code in from above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment