Validate E-Mail Script

$(document).ready(function(e) {
$(‘#email’).click(function() {
var sEmail = $(‘#txtEmail’).val();
if ($.trim(sEmail).length == 0) {
new Messi(‘Please enter valid email address’, {center: false, viewport: {top: ‘380px’, left: ‘500px’}});// this is jquery 3rd party plugin to change default alert box.
if (validateEmail(sEmail)) {
$.post(“mail.php”, { txtEmail: $(‘#txtEmail’).val() },function(data) {   // This is to post url to server
//alert(“Data Loaded: ” + data);
new Messi(‘<b style=”font-family: Segoe UI;font-size:14px;”>Check Your E-Mail in Inbox/Junk Box !!</b>’,{title: ‘<b style=”font-family: Cambria;font-size:15px;”>Email Sent</b>’});

} );

else {
new Messi(‘<b style=”font-family: Segoe UI;font-size:14px;”>Invalid Email Address.</b>’,{title: ‘<b style=”font-family: Cambria;font-size:16px;”>Invalid Email</b>’});

function validateEmail(sEmail) {
var filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (filter.test(sEmail)) {
return true;
else {
return false;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s