I have a "Coming soon" page but i want to add an "insert your e-mail" option and the e-mail to be inserted on a csv or txt file. What i have is an ajax validate e-mail address and the input field:
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[w-s]+")|([w-]+(?:.[w-]+)*)|("[w-s]+")([w-]+(?:.[w-]+)*))(@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$)|(@[?((25[0-5].|2[0-4][0-9].|1[0-9]{2}.|[0-9]{1,2}.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2}).){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})]?$)/i);
return pattern.test(emailAddress);
}
/*FORM validation and div changing*/
$(document).ready(function() {
$().click(function (ev) {
var $target = $(ev.target);
if( !$target.is("input") ) {
$("input#email").val('Vendosni e-mail tuaj qe tju njoftojme per hapjen e faqes');
}
});
$("#email").click(function() {
$("input#email").val('');
});
$("#submit").click(function() {
var email = $("input#email").val();
if(!isValidEmailAddress(email)){
$("input#email").focus();
$("input#email").val('Vendosni nje e-mail te sakte');
return false;
}
});
/*form submit*/
$("form#form-email").submit(function() {
var email = $("input#email").val();
$.ajax({
url:'mail.php',
type:'post',
data: "email="+email,
success: function(msg){
if (msg==1)
$("input#email").val('Ju faleminderit! Deshironi te regjistroni nje e-mail tjeter ?');
else
$("input#email").val('Gabim! Ndodhi nje gabim ne dergim!');
}
});
return false;
});
/*end formsubmit*/
});
<form action="mail.php" method="post" id="form-email">
<p>
<input type="text" name="email" id="email" value="Vendosni e-mail tuaj qe tju njoftojme per hapjen e faqes"/>
</p>
<p>
<input type="submit" name="submit" id="submit" value="" />
</p>
</form>
Hope that you can help me on this.