function memberRegister() { document.getElementById("register_validation").innerHTML = ""; var firstname = document.forms["dialog_form_register"]["firstname"].value.trim(); var lastname = document.forms["dialog_form_register"]["lastname"].value.trim(); var email = document.forms["dialog_form_register"]["email"].value.trim(); var password = document.forms["dialog_form_register"]["password"].value.trim(); var repassword = document.forms["dialog_form_register"]["repassword"].value.trim(); var mobile = document.forms["dialog_form_register"]["mobile"].value.trim(); if (document.forms["dialog_form_register"]["checkbox_tnc"].checked==false) { document.getElementById("register_validation").innerHTML = "
Please accept the Terms and Conditions to proceed.
"; return; } //tnc_accept_error if (isEmptyString(firstname) || isEmptyString(lastname) || isEmptyString(email) || isEmptyString(password) || isEmptyString(repassword)) { document.getElementById("register_validation").innerHTML = "
? required field(s)
"; return; } if (firstname.length<2) { document.getElementById("register_validation").innerHTML = "
Please fill in correct first name
"; return; } if (lastname.length<2) { document.getElementById("register_validation").innerHTML = "
Please fill in correct last name
"; return; } if (checkemail(email)==false) { document.getElementById("register_validation").innerHTML = "
Please fill in correct email
"; return; } if (mobile.length!=8) { document.getElementById("register_validation").innerHTML = "
Please fill in correct mobile.
"; return; } if (password.length<6 || repassword.length<6) { document.getElementById("register_validation").innerHTML = "
Password requires at least 6 characters.
"; return; } if (password!=repassword) { document.getElementById("register_validation").innerHTML = "
Password doest not match
"; return; } //alert("ajax_ cala:"+ $("#dialog_form_register").serialize()); $.ajax({ url : '/ajax_api/member_register.jsp', type: 'POST', data: $("#dialog_form_register").serialize(), success : function(data,status, jqXHR) { //alert(data); var obj = JSON.parse(data); if (obj.resultCode=="0000") { //reload the data //document.getElementById("register_result").innerHTML = ""; document.getElementById("register_result").innerHTML = "
"+obj.message+"
"; //location.reload(); setTimeout(function(){ location.reload(); },500); } else { //show for the error document.getElementById("register_result").innerHTML = "
"+obj.message+"
"; } } , error: function (jqXHR, status, err) { }, complete: function (jqXHR, status) { setTimeout(function(){ },200); } }) } function checkemail(email){ var testresults= true; var str=email; var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (filter.test(str)) testresults=true else{ testresults=false } return (testresults) } function isEmptyString(str) { var ans = 0 var ansStr = "" if (str=="") return 1 for (var i = 0; i < str.length; i++) { var ch = str.substring(i, 1) if (ch != " ") ansStr += ch } if (ansStr == "") ans = 1 return ans // answer 1 if it is an empty string, otherwise answer 0. } function passwordReset() { var email = document.forms["dialog_form_pw_reset"]["email_recovery"].value; var lastsesison = document.forms["dialog_form_pw_reset"]["lastsesison"].value; if (isEmptyString(email) ) { document.getElementById("recovery_result").innerHTML = "
? required field(s)
"; return; } if (checkemail(email)==false) { document.getElementById("recovery_result").innerHTML = "
Please fill in correct email
"; return; }  var dataString= 'email='+ email +'&lastsesison='+ lastsesison; var actionURL='/ajax_api/member_password_reset.jsp'; document.getElementById("login_result").innerHTML =""; getResetPWResult(actionURL,dataString); } function getResetPWResult(actionURL, dataString) {   $.ajax({ url : actionURL, type: 'POST', data: dataString, success : function(data,status, jqXHR) { //alert(data); var obj = JSON.parse(data); if (obj.resultCode=="0000") { //reload the data document.getElementById("dialog_form_pw_reset").innerHTML = "
The new password has been sent, please check the password from your email.
"; //document.getElementById("dialog_form_pw_reset").innerHTML = ""; // if (obj.resultURL){ // window.location.href=obj.resultURL; // } // else // { // location.reload(); // } } else { //show for the error document.getElementById("dialog_form_pw_reset").innerHTML = "
"+obj.message+"
"; } } , error: function (jqXHR, status, err) { }, complete: function (jqXHR, status) { setTimeout(function(){ },200); } }) } function memberLogin() { var email = document.forms["login_form"]["email"].value; var password = document.forms["login_form"]["password"].value; var lastsesison = document.forms["login_form"]["lastsesison"].value; if (isEmptyString(email) || isEmptyString(password)) { document.getElementById("login_result").innerHTML = "
? required field(s)
"; return; } if (email.length!=8 && checkemail(email)==false ) { document.getElementById("login_result").innerHTML = "
Please fill in correct email or mobile.
"; return; } if (password.length<6) { document.getElementById("login_result").innerHTML = "
Password requires at least 6 characters.
"; return; }  var dataString= 'email='+ email + '&password='+ password + '&lastsesison='+ lastsesison; //do ajax //alert("memberLogin/"+email+"/"+password+"/"+dataString); var actionURL='/ajax_api/member_login.jsp'; document.getElementById("login_result").innerHTML =""; getLoginResult(actionURL,dataString); } function getLoginResult(actionURL, dataString) {   $.ajax({ url : actionURL, type: 'POST', data: dataString, success : function(data,status, jqXHR) { var obj = JSON.parse(data); if (obj.resultCode=="0000") { //reload the data document.getElementById("login_result").innerHTML = ""; if (obj.resultURL){ window.location.href=obj.resultURL; } else { location.reload(); } } else { //show for the error document.getElementById("login_result").innerHTML = "
"+obj.message+"
"; } } , error: function (jqXHR, status, err) { }, complete: function (jqXHR, status) { setTimeout(function(){ },200); } }) }