$.validator.setDefaults({
submitHandler: function() {
}
});
$().ready(function() {
$("#Register").validate({
rules: {
mobile: {
required: true,
minlength: 10
},
password: {
required: true,
minlength: 5
},
rcode: {
required: true,
minlength: 6
},
remember: "required",
},
messages: {
password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
},
remember: "Please accept our policy",
}
});
});
//===============================================login validation=======================================================
$().ready(function() {
$("#loginForm").validate({
rules: {
login_mobile: {
required: true,
minlength: 10
},
login_password: {
required: true,
minlength: 5
},
},
messages: {
password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
},
remember: "Please accept our policy",
}
});
});
$(document).ready(function () {
$("#Register").on('submit',(function(e) {
e.preventDefault();
var mobile = $('input#mobile').val();
var password = $('input#password').val();
var rcode = $('input#rcode').val();
if ((mobile)== "") {
$("input#mobile").focus();
$('#mobile').addClass('borderline');
return false;
}
if (mobile.length<10) {
$("input#mobile").focus();
$('#mobile').addClass('borderline');
return false;
}
if ((password)== "") {
$("input#password").focus();
$('#password').addClass('borderline');
return false;
}
if (password.length<5) {
$("input#password").focus();
$('#password').addClass('borderline');
return false;
}
if ((rcode)== "") {
$("input#rcode").focus();
$('#rcode').addClass('borderline');
return false;
}
if($('#remember').is(':checked')){}
else{return false;}
$.ajax({
type: "POST",
url: "registerNow.php",
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(html)
{ //alert(html);
var arr = html.split('~');
if (arr[0]== 1) {
$("#Register")[0].reset();
//window.location.href = "successvisitorNow";
$('#registerthanksPopup').modal({backdrop: 'static', keyboard: false})
$('#registerthanksPopup').modal('show');
}
else if (arr[0]== 2) {
document.getElementById('regtoast').innerHTML = ('Mobile Number allready register with us !');
$('#registertoast').modal({backdrop: 'static', keyboard: false})
$('#registertoast').modal('show');
}
else if (arr[0]== 3) {
document.getElementById('regtoast').innerHTML = ('Wrong recommendation code enter !');
$('#registertoast').modal({backdrop: 'static', keyboard: false})
$('#registertoast').modal('show');
}
else if (arr[0]== 4) {
document.getElementById('regtoast').innerHTML = ('Please verify your mobile no. !');
$('#registertoast').modal({backdrop: 'static', keyboard: false})
$('#registertoast').modal('show');
}
else if(arr[0]==0)
{ document.getElementById('serror').innerHTML = ('Some Technical error !');
}
}
});
}));
//=====================Login Script================================================================
$("#loginForm").on('submit',(function(e) {
e.preventDefault();
var loginmobile = $('input#login_mobile').val();
var loginpassword = $('input#login_password').val();
if ((loginmobile)== "") {
$("input#login_mobile").focus();
$('#login_mobile').addClass('borderline');
return false;
}
if (loginmobile.length<10) {
$("input#login_mobile").focus();
$('#login_mobile').addClass('borderline');
return false;
}
if ((loginpassword)== "") {
$("input#login_password").focus();
$('#login_password').addClass('borderline');
return false;
}
if (loginpassword.length<5) {
$("input#login_password").focus();
$('#login_password').addClass('borderline');
return false;
}
$.ajax({
type: "POST",
url: "loginNowAgent.php",
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(html)
{ //alert(html);
var arr = html.split('~');
if (arr[0]== 2) {
window.location.href = "agentaccount.php";
}
else if(arr[0]==0)
{ document.getElementById('regtoast').innerHTML = ('Wrong mobile number or password Entered !');
$('#registertoast').modal({backdrop: 'static', keyboard: false})
$('#registertoast').modal('show');
}
}
});
//=====================change password================================================================
}));
//================================================match otp===================================================
$("#otpsubmitForm").on('submit',(function(e) {
e.preventDefault();
var otp = $('input#otp').val();
if ((otp)== "") {
$("input#otp").focus();
$('#otp').addClass('borderline');
return false;
}
$.ajax({
type: "POST",
url: "veryfynumberNow.php",
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(html)
{ //alert(html);
var arr = html.split('~');
if (arr[0]== 1) {
$("#otpclose").click();
document.getElementById('regtoast').innerHTML = ('Verification Succesfully !');
$('#registertoast').modal({backdrop: 'static', keyboard: false})
$('#registertoast').modal('show');
$('#mobile').attr('readonly', true);
}
else if(arr[0]==0)
{ document.getElementById('regtoast').innerHTML = ('Wrong OTP Entered !');
$('#registertoast').modal({backdrop: 'static', keyboard: false})
$('#registertoast').modal('show');
}
}
});
//=====================change password================================================================
}));
});
function mobileveryfication(){
var mobile = $('input#mobile').val();
if ((mobile)== "") {
$("input#mobile").focus();
$('#mobile').addClass('borderline');
return false;
}
if (mobile.length<10) {
$("input#mobile").focus();
$('#mobile').addClass('borderline');
return false;
}
$.ajax({
type: "Post",
data:"mobile=" + mobile+ "& type=" + "mobile",
url: "veryfynumberNow.php",
success: function (html) {
//alert(html);
var arr = html.split('~');
if (arr[0]== 1) {
//data = JSON.parse(arr[1])
//alert(data.Status);
//alert(data.Details);
$('#otpform').modal({backdrop: 'static', keyboard: false})
$('#otpform').modal('show');
}
else if (arr[0]== 2) {
document.getElementById('regtoast').innerHTML = ('Mobile Number allready register with us !');
$('#registertoast').modal({backdrop: 'static', keyboard: false})
$('#registertoast').modal('show');
}
return false;
},
error: function (e) {}
});
}