var formFields = $('#form .requiredMe'); var formSelect = $('#form .requiredMe'); var colNum = { 'SG': '8123 4567', 'MY': '12-345 6789', 'PH': '905 123 4567', 'HK': '5123 4567', 'ID': '812-345-678', 'VN': '91 234 56 78', 'TW': '912 345 678', 'TH': '81 234 5678', 'CN': '131 2345 6789', 'MC': '8312 3456' }; var countryCode = { 'SG': '+65', 'MY': '+60', 'PH': '+63', 'HK': '+852', 'ID': '+62', 'VN': '+84', 'TW': '+886', 'TH': '+66', 'CN': '+86', 'MC': '+853' }; var flagList = { 'SG': '1898be2c-576f-4a93-af3f-f7df8913556e.png', 'TW': 'dfc9c220-f570-45d1-9761-6700d7ece7d3.png', 'PH': 'f8947c52-139f-42df-8c3d-251c57b1db6d.png', 'TH': 'ecf087f6-c5ee-4b8c-9f23-76948ba09779.png', 'ID': '9bb59fa5-0424-4eb9-acd3-b32fae2c8217.png', 'CN': 'aea1efa7-830d-481f-875c-827ed4b982c0.png', 'VN': 'db12c508-a072-44a8-8b26-a28b2307eba0.png', 'HK': '44461072-82bb-4c3d-beb3-e0a029cd2c9a.gif', 'MY': 'bf5848f4-27a1-441f-a308-290c9f88be92.png', 'MC': '5a90f657-8560-4d76-a903-1ed9beece4ad.png' }; var consent = { 'SG': 'By submitting this form, I understand and expressly consent that any personal data which I have provided may be processed by Luxasia for marketing purposes and for purposes specified in Luxasia's Privacy Policy. See www.luxasia.com/privacy/ for more details.', 'MY': 'By submitting this form, I understand and expressly consent that any personal data which I have provided may be processed by Luxasia for marketing purposes and for purposes specified in Luxasia's Privacy Policy. See www.luxasia.com/privacy/ for more details.', 'PH': 'By submitting this form, I understand and expressly consent that any personal data which I have provided may be processed by Luxasia for marketing purposes and for purposes specified in Luxasia's Privacy Policy. See www.luxasia.com/privacy/ for more details.', 'HK': 'By submitting this form, I understand and expressly consent that any personal data which I have provided may be processed by Luxasia for marketing purposes and for purposes specified in Luxasia's Privacy Policy. See www.luxasia.com/privacy/ for more details.', 'ID': 'By submitting this form, I understand and expressly consent that any personal data which I have provided may be processed by Luxasia for marketing purposes and for purposes specified in Luxasia's Privacy Policy. See www.luxasia.com/privacy/ for more details.', 'VN': 'By submitting this form, I understand and expressly consent that any personal data which I have provided may be processed by Luxasia for marketing purposes and for purposes specified in Luxasia's Privacy Policy. See www.luxasia.com/privacy/ for more details.', 'TW': '通過提交此表格, 我明白並同意所提供的任何個人資料可能會被盧亞公司用於市場行銷推廣或隱私權政策中指定的目的. 詳情請參閱www.luxasia.com/privacy/)', 'TH': 'เพื่อเป็นการแสดงว่าท่านได้ยินยอม / ยอมรับ ในแบบฟอร์มนี้ ตามข้อมูลส่วนบุคคของท่านที่ได้ระบุไว้ จะถูกเก็บรวบรวมและดำเนินการโดยบริษัทลัคซ์เอเซีย เพื่อวัตถุประสงค์ทางการตลาดและวัตถุประสงค์ที่ระบุในนโยบายความเป็นส่วนตัวของบริษัทฯ(สามารถดูรายละเอียดได้ที่ www.luxasia.com/privacy/)', 'CN': 'By submitting this form, I understand and expressly consent that any personal data which I have provided may be processed by Luxasia for marketing purposes and for purposes specified in Luxasia's Privacy Policy. See www.luxasia.com/privacy/ for more details.' }; var x = setInterval(function() { var now = new Date().getTime(); var distance = countDownDate - now; var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); $('.ctmDay span').html(days); $('.ctmHour span').html(hours); $('.ctmMins span').html(minutes); $('.ctmSecs span').html(seconds); if (distance < 0) { clearInterval(x); $('.ctmBox').addClass('thisHide'); $(".countMeDown").append('

' + messageClosed + '' + contactMe + '' + extraMessageClosed + '

'); $('.formCont').addClass('thisHide'); } }, 1000); function createRangeDesc(start, stop) { var sHtml = ''; for (i = stop; i > start; i--) { sHtml += ''; } return sHtml; }; function createRangeAsc(start, stop) { var sHtml = ''; for (i = start; i < stop; i++) { sHtml += ''; } return sHtml; }; function createRangeMonth() { var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; for (var month = 0; month <= 11; month++) { $("#dobMM").append(''); } }; var currentYear = new Date().getFullYear(); var monthRange = createRangeMonth(); var dayRange = createRangeAsc(1, 32); var yearRange = createRangeDesc(1920, currentYear); $('#dobMM').append(monthRange); $('#dobDD').append(dayRange); $('#dobYY').append(yearRange); $('#full_phone_number').keyup(function(e) { if (/\D/g.test(this.value) || /^0/gi.test(this.value)) { this.value = this.value.replace(/\D/g, ''); this.value = this.value.replace(/^0/gi, ''); } }); $("#flagHerechoose").val($("#flagHerechoose option:first").val()); var cp2 = $("#flagHerechoose").val(); $.each(colNum, function(key, value) { if (key == cp2) { var numVal = value; if(cp2 == 'HK' || cp == 'TW'){ var countVal = numVal.match(/\d/g).length; } else if(cp2 == 'ID'){ var countVal = 11; } else{ var countVal = numVal.match(/\d/g).length; } $('#full_phone_number').attr('placeholder', value); $('#full_phone_number').attr('maxlength', countVal); }; }); $.each(flagList, function(key, value) { if (key == cp2) { var flatUrl = value; $('.flagHerechoose').css('background-image', 'url("http://image.e.luxasia.com/lib/fe4615707564047c731570/m/1/' + flatUrl + '")'); }; }); $.each(consent, function(key, value) { if (key == cp2) { var consentMessage = value; $('.consentCont p').html(consentMessage); }; }); $.each(countryCode, function(key, value){ if (key == cp2) { var codeCountry = value; $('.flagHere').html('

'+ codeCountry +'

'); }; }); $.each(flagList, function(key, value) { if (key == cp2) { var flatUrl = value; $('.flagHerechoose').css('background-image', 'url("http://image.e.luxasia.com/lib/fe4615707564047c731570/m/1/' + flatUrl + '")'); }; }); function defaultFlagOnChange() { $("#flagHerechoose").on("change", function () { var cp = $("#flagHerechoose").val(); $.each(colNum, function(key, value) { if (key == cp) { var numVal = value; if(cp == 'HK' || cp == 'TW'){ var countVal = numVal.match(/\d/g).length; } else if(cp == 'ID'){ var countVal = 11; } else{ var countVal = numVal.match(/\d/g).length; } $('#full_phone_number').attr('placeholder', value); $('#full_phone_number').attr('maxlength', countVal); }; }); $.each(flagList, function(key, value) { if (key == cp) { var flatUrl = value; $('.flagHerechoose').css('background-image', 'url("http://image.e.luxasia.com/lib/fe4615707564047c731570/m/1/' + flatUrl + '")'); }; }); $.each(consent, function(key, value) { if (key == cp) { var consentMessage = value; $('.consentCont p').html(consentMessage); }; }); $.each(countryCode, function(key, value){ if (key == cp) { var codeCountry = value; $('.flagHere').html('

'+ codeCountry +'

'); }; }); }); }; defaultFlagOnChange(); function defaultFlag() { defaultFlagOnChange(); var cp3 = $("#flagHerechoose").val(); $.each(countryCode, function(key, value){ if (key == cp3) { var codeCountry = value; var clearCodeCountry = codeCountry.replace(/[^0-9\.]/g, ''); var inputedContact = $('#full_phone_number').val(); $('#full_phone_number2').val(clearCodeCountry + inputedContact); }; }); }; defaultFlag(); function changeThis() { var valChange = $(this).val(); if (valChange == '' || valChange == ' ') { $(this).addClass('errorThis'); } else { $(this).removeClass('errorThis'); } $('#dob').val($('#dobMM').val() + ' ' + $('#dobDD').val() + ', ' + $('#dobYY').val()); }; formFields.change(changeThis); formSelect.change(changeThis); $('#email').change(function() { var veriEmail = $('#email').val(); var filter = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,6})?$/; if (filter.test(veriEmail) && veriEmail != '') { $('#email').removeClass('errorThis'); return true; } else { $('#email').addClass('errorThis'); return false; } }); /*function checkErrorField() { $.each(formFields, function() { if ($(this).val() == '') { $(this).addClass("errorThis"); } }); $.each(formSelect, function() { if ($(this).val() == '') { $(this).addClass("errorThis"); } }); $.each(countryCode, function(key, value){ if (key == cp) { var codeCountry = value; var clearCodeCountry = codeCountry.replace(/[^0-9\.]/g, ''); var inputedContact = $('#full_phone_number').val(); $('#full_phone_number2').val(clearCodeCountry + inputedContact); }; }); };*/ function setDefault() { $('#dobMM').val(''); $('#dobDD').val(''); $('#dobYY').val(''); $('#countMeFailed').val(0); }; $('#email').on('change', function() { var email = $('#email').val(); var url = 'https://bpi.briteverify.com/emails.json?address=' + email + '&apikey=eecfb2c4-cb68-4739-9de3-e6eb2e10131e'; console.log(url); $.ajax({ url: url, type: 'GET', dataType: 'jsonp', success: function(data) { console.log(data); if (data.status == 'valid'){ $('#email').removeClass("errorThis"); $('.errorBox').addClass("thisHide"); } else if (data.status == 'accept_all'){ $('#email').removeClass("errorThis"); $('.errorBox').addClass("thisHide"); } else { $('#email').addClass("errorThis"); $('.errorBox').removeClass("thisHide"); var briteverifyFailedCount = $('#countMeFailed').val(); var emailFailedCount = parseInt(briteverifyFailedCount) + 1; $('#countMeFailed').val(emailFailedCount); } }, }); }); function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } var dynamicContent = getParameterByName('cf'); $("#utm_camefrom").val(dynamicContent); $('#getmyurl').val(window.location.href); var dobMMPop = $('#dobMMPop').val(); var dobDDPop = $('#dobDDPop').val(); var dobYYPop = $('#dobYYPop').val(); if (dobMMPop != '' || dobMMPop != '' || dobMMPop != '') { var dobMMPop = $('#dobMMPop').val(); var dobMMPopVal = Number(dobMMPop).toString(); $('#dobMM option[value=' + dobMMPopVal + ']').attr('selected', true); var dobDDPop = $('#dobDDPop').val(); var dobDDPopVal = Number(dobDDPop).toString(); $('#dobDD option[value=' + dobDDPopVal + ']').attr('selected', true); var dobYYPop = $('#dobYYPop').val(); var dobYYPopVal = Number(dobYYPop).toString(); $('#dobYY option[value=' + dobYYPopVal + ']').attr('selected', true); } var slotVal = $('.slotBox span').html(); var slotAvailable = SlotNumber - slotVal; var slot = slotAvailable; $('.slotBox p span').html(slotAvailable); $( "#submit" ).click(function() { var first_name = $("#first_name").val().trim(); var last_name = $("#last_name").val().trim(); var full_phone_number = $("#full_phone_number").val().trim(); var dob = $("#dob").val().trim(); var locationSelected = $("#locationSelected").val().trim(); var email = $("#email").val(); function validateEmail($email) { var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; return emailReg.test( $email ); } if((first_name != '') && (last_name != '') && (full_phone_number != '') && (dob != '') && (locationSelected != '') && (email != '') && (validateEmail(email))){ defaultFlag(); // defaultFlagOnChange(); //alert($('#full_phone_number2').val()); $("#popUpMessage").removeClass("thisHide"); $(this).submit(); } else { //event.preventDefault(); } }); $("#closeThis").click(function() { $("#popUpMessage").addClass("thisHide"); var inputs = document.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { if (inputs[i].type == "text" || inputs[i].type == "email" || inputs[i].type == "tel") { inputs[i].value = ""; } } var slotBoxCurNum = $('.slotBox p span').html(); var slotBoxCurNumNext = slotBoxCurNum - 1; $('.slotBox p span').html(slotBoxCurNumNext); setDefault(); });