$(document).on('input','.aanvragen_input','',function(){
$(this).removeClass('error_required');
});
/*
const validateEmail = (email) => {
return email.match(
/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
);
};
*/
function validateEmail(email)
{
// var re = /\S+@\S+\.\S+/;
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
$(document).on('click','#account_aanvragen','',function(){
//alert('login_password: '+$('.pwpwpw').val());
//alert('bevestig_password: '+$('#bevestig-password').val());
//validation
var formdata = new Object();
var error = "";
$('.aanvragen_input').each(function(){
formdata[$(this).attr('name')] = $(this).val();
if($(this).hasClass('required') && $(this).val()==''){
$(this).addClass('error_required');
error += $(this).attr('placeholder')+' is een verplicht veld!
';
}
});
var emailval = $('#debiteurEmail').val();
if (!validateEmail(emailval) && emailval != ''){
error += ''+$('#debiteurEmail').val()+' is niet een correct e-mailadres!
';
$('#debiteurEmail').addClass('error_required');
}
if ($('#login_password_2').val()!=$('#bevestig-password').val()) {
error += 'Wachtwoorden komen niet overeen!
';
}
if(error!=''){
wl_alert('alert',error);
return false;
}else{
$.ajax({
url: '../process_ajax.php',
type: 'POST',
data: {task:'create_account',post:formdata},
cache: false,
success: function (html) {
wl_alert('alert',html,goto_homepage);
},
error: function(error){
////// wl_alert('alert','Connection lost, please try again.' + error,false,false,'Ok','',false);
wl_alert('alert','Connection lost, please try again!',false,false,'Ok','',false);
//console.log('error'+error);
},
complete: function(){
$('.loading').hide();
}
});
}
});
function goto_homepage(){
$('#home').trigger('click');
}
function focus_email_field(){
var deze = $('#debiteurEmail');
deze.addClass('error_required');
deze.val('');
deze.focus();
}
$(document).on('change','#debiteurEmail','',function(){
var deze = $(this);
var deze_val = deze.val();
var error = "";
if(deze_val != ''){
$.ajax({
url: '../process_ajax.php',
type: 'POST',
data: {task:'check_email',email_adres:deze_val},
cache: false,
success: function (html) {
if (html != ''){
wl_alert('alert',html,focus_email_field);
}
},
error: function(error){
////// wl_alert('alert','Connection lost, please try again.' + error,false,false,'Ok','',false);
wl_alert('alert','Connection lost, please try again!',false,false,'Ok','',false);
//console.log('error'+error);
},
complete: function(){
$('.loading').hide();
}
});
}
});