-
-
Save lagolucas/79dddd6edf1b84ca4636b0fb5c455502 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<form method="post" name="subscribeform" id="subscribeform" enctype="multipart/form-data"> | |
<table border=0> | |
<tr> | |
<td><div class="required">Email</div></td> | |
<td class="attributeinput"><input type="text" name="email" value="" id="email" size="40"></td> | |
</tr> | |
</table> | |
<input type=hidden name="htmlemail" value="1"> | |
<input type=hidden name="list[4]" value="signup"> | |
<input type=hidden name="list[2]" value="signup"> | |
<input type="hidden" name="subscribe" value="subscribe"/> | |
<div style="display:none"><input type="text" name="VerificationCodeX" value="" size="20"></div> | |
<button class='button' | |
onclick="if (checkform()) {submitForm();} return false;" | |
>Subscribe</button> | |
<div id="result" style="color: red;"></div> | |
</form> | |
<script type="text/javascript"> | |
function checkform() | |
{ | |
re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; | |
if (!(re.test(jQuery("#email").val()))) { | |
jQuery("#result").empty().append("Please enter a valid email address"); | |
jQuery("#email").focus(); | |
return false; | |
} | |
if (jQuery("#password").val() == "") { | |
jQuery("#result").empty().append("Please enter your password"); | |
jQuery("#password").focus(); | |
return false; | |
} | |
return true; | |
} | |
function submitForm() { | |
successMessage = 'Thank you for your registration. Please check your email to confirm.'; | |
data = jQuery('#subscribeform').serialize(); | |
jQuery.ajax( { | |
type: 'POST', | |
data: data, | |
url: 'http://newsletter.homologacao.devsys.nic.br/?p=asubscribe&id=3', | |
dataType: 'html', | |
success: function (data, status, request) { | |
jQuery("#result").empty().append(data != '' ? data : successMessage); | |
jQuery('#password').val(''); | |
jQuery('#email').val(''); | |
}, | |
error: function (request, status, error) { alert('Sorry, we were unable to process your subscription.'); } | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment