function validateEmail(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (regex.test(email)) {
$.ajax({
url: '/users/checkmail',
data: {
email: email
},
method: 'post',
success: function (res) {
$("#email_prev").html(res);
if (res == "available") {
$("#store_email").attr('data-valid', 'true');
return true;
} else {
$("#store_email").attr('data-valid', 'false');
return false;
}
}
});