Created
April 29, 2011 19:53
-
-
Save jakebellacera/948916 to your computer and use it in GitHub Desktop.
A super advanced JS emailer. Uses the JQuery Validation plugin.
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
/** | |
* Mail.js 1.1 | |
* =========== | |
* A simple AJAX emailer | |
*/ | |
$(function(){ | |
$('#mailform').validate({ | |
// Set rules for special fields (email/phone) | |
rules: { | |
email: { | |
required: true, | |
email: true | |
} | |
}, | |
submitHandler: function(form) { | |
// Create variables from form | |
var fname = $("input#fname").val(); | |
var lname = $("input#lname").val(); | |
var email = $("input#email").val(); | |
var phone = $("input#phone").val(); | |
// Who's dat? | |
var fullname = fname + ' ' + lname; | |
// Create variables that will be sent in a URL string to mail.php | |
var dataString = '&name=' + fullname + '&email=' + email + '&phone=' + phone; | |
// The AJAX | |
$.ajax({ | |
type: "POST", | |
url: "/clients/ace_of_spades-fullsite/etc/mail.php", | |
data: dataString, | |
success: function() { | |
// AJAX output | |
$("#shadow").fadeIn(); | |
$("#mailbox").fadeIn(); | |
$(':input','#mailform') | |
.not(':button, :submit, :reset, :hidden') | |
.val('') | |
.removeAttr('checked') | |
.removeAttr('selected'); | |
return false; | |
} | |
}); | |
return false; | |
} | |
}); | |
$("#closebutton").click(function(){ | |
$("#shadow").fadeOut(); | |
$("#mailbox").fadeOut(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment