Server sided mail checking...

This commit is contained in:
Joe
2017-02-07 22:40:37 -06:00
parent 3bed9f1986
commit f5e1367e57
3 changed files with 34 additions and 5 deletions

3
checkMail.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
echo shell_exec('./checkmail.sh \'' . $_GET['mailAddress'] . '\'');
?>

View File

@@ -1,6 +1,5 @@
/*globals $,ibuyproperties,window*/
// R O O T E R
ibuyproperties.router=(function(){
var allRoutes=[];

View File

@@ -1,16 +1,43 @@
<script>
function checkEMail(theEmailAddress){
return (/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/.test(theEmailAddress));
var def = new $.Deferred()
var patternMatch=(/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/.test(theEmailAddress));
if (patternMatch ) {
$.ajax({
type:"GET",
url:"/checkMail.php",
dataType:"json",
contentType:"application/json",
data: { "mailAddress" : theEmailAddress},
success:function(msg,jqXHR,status) {
console.log("send-success method mailcheck ",msg,jqXHR,status);
if (msg.status != "ok") {
def.resolve();
} else {
def.reject(msg);
}
},
error:function(jqXHR,status,error){
console.log("send-error method mailcheck ",jqXHR,status,error);
def.reject(jqXHR);
}
});
} else {
def.reject("{status:'error', msg:'pattern not matching e-mail format.'}")
}
return def.promise();
}
function nextHandler(){
$("#alertInvalidEMail").addClass("hide");
if(checkEMail($($('[name="email"]')[0]).val())){
checkEMail($($('[name="email"]')[0]).val()).then(function(){
window.location="#Sell/page2/";
} else {
}).fail(function(data){
if (ibuyproperties.isDebugMode) { console.log("EMail Wrong"); }
$("#alertInvalidEMail").removeClass("hide");
}
console.error("E-Mail check error",data)
});
}
</script>