function validmail(email) { var re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm if (email == '' || !re.test(email)) { console.log('Please enter a valid email address: ', email); return false; } else { var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/; if (!filter.test(email)) { console.log('2.Please enter a valid email address: ', email); return false; } var atpos = email.indexOf("@"); var dotpos = email.lastIndexOf("."); if (atpos<1 || dotpos=email.length) { console.log("Not a valid e-mail address"); return false; } return true; } } $(document).ready( function(){ // $("input[name='birthday']").datepicker({format:"mm/dd/yyyy",viewMode:2});; // Handle form submit for validation $("#login_form").submit( function(e){ // Check if form has class submit if (!$("#login_form").hasClass("submit")){ e.preventDefault(); // Check if inputs have value $("#login_form input[type='text'], #login_form input[type='password']").each( function(){ if( $(this).val()==""){ $(this).addClass("required"); } else{ $(this).removeClass("required"); } }); if( $("#login_form .required").length==0 ){ $("#login_form").addClass("submit"); $("#login_form").submit(); } } }); // Create account button, registration form $(".create_account").click( function(){ // Check if all required fields have values var submit = true; var currenturl = $('.currenturl').val(); /* $(".signup_form input").each( function(){ if ($(this).attr("name")!='fileToUpload' && $(this).attr("id")!="uploadFile" ) { var input_value = $(this).val(); var input_name = $(this).attr("name"); // If a required fields is empty add "error" class to it if(input_value==""){ $(this).addClass("error"); submit = false; } } }); */ $("input[is_required='true']").each( function(){ var input_value = $(this).val(); var input_name = $(this).attr("name"); // If a required fields is empty add "error" class to it var typeM=$(this).attr("type"); if(typeM=='email' ) { //console.log(input_name, typeM, input_value, validmail(input_value)) ; if(!validmail(input_value)) { input_value=''; } } if(typeM=='checkbox') { //console.log($('input[name="CARes"]').is(':checked')) ; if($('input[name="CARes"]').is(':checked')){ $(this).parent().css("border", "none"); }else { input_value=''; $(this).parent().css("border", "1px solid red"); } } if(input_value==""){ $(this).addClass("error"); submit = false; } }); // If all required fields have values, do ajax call to create new customer if(submit){ // Get form var form = $('#signup_form')[0]; // Create an FormData object var data = new FormData(form); // If you want to add an extra field for the FormData //data.append("CustomField", "This is some extra data, testing"); // disabled the submit button //$("#btnSubmit").prop("disabled", true); $.ajax({ url: "https://tickets.pacpark.com/en/ajax_calls/sign-up/&modonly=1", type: "post", enctype: 'multipart/form-data', data: data, processData: false, contentType: false, cache: false, timeout: 600000, success: function(data){ console.log(data); if (data=='loggedin') { document.location.href=('/en/'+currenturl); } /* $('.signup_form_container').html("
Succesfully stored your information!
Please click here to proceed.
"); */ if (data=='errorlogin') { $('.signup_form_container').html("
Your account is ready! Please click here to login.
"); } if (data=='errordoublecustomer') { $('.captcha_error').html("You have previously used our store. Please use the login button to access your personal details. If you do not have a password, you can use the password reset button to have one sent in your email."); grecaptcha.reset() } if (data=='errorcustomer') { $('.captcha_error').html("Please check the reCAPTCHA checkbox to declare your valid information"); grecaptcha.reset(); } }, error: function(data){ console.log(data); alert("There was an error. Please try again."); } }); // end of ajax call } }); $(".signup_form").on( "click keyup", "input", function(){ $(this).removeClass("error"); }); $(".order_row").on( "click", ".order_details", function(){ var order_id = $(this).attr("rel"); window.location.href = "https://tickets.pacpark.com/en/customer/order/&tid="+order_id; }); // Checkbox "Show password" in log in form $("#showpass").change( function(){ if( $("#showpass").is(":checked") ){ $("input[name='password']").attr("type","text"); } else{ $("input[name='password']").attr("type","password"); } }); });