'); $("#leadform").append(''); $("#leadform").append(''); $("#leadform").append(''); $("#leadform").append(''); $("#leadform").append(''); $("#leadform").append(''); $("#leadform").append(''); $("#leadform").append(''); $("#leadform").append(''); $("#leadform").append(''); var recapchaKey = window.GLOBAL_VARIABLES.recaptchaSitekey; grecaptcha.enterprise.ready(function() { grecaptcha.enterprise.execute(recapchaKey, { action: 'validate_captcha'}).then(function(token) { $("#leadform").prepend(''); var url = "/ck/en/leadform"; $.ajax({ url: url, type: 'POST', data: new FormData($('form[name=leadform]')[0]), contentType: false, cache: false, processData: false, beforeSend: function () { $('#l-loading').show(); $('button[name=btnSubmit]').prop('disabled', true); }, success: function (dataJS) { var data = JSON.parse(dataJS); if (data['status'] !== undefined && data['status'] === "success") { $('form[name=leadform]').hide(); $('#l-loading').hide(); $('button[name=btnSubmit]').prop('disabled', false); $.ajax({ url: "/ck/en/getverifyform", type: 'POST', success: function (response) { $("#form-outer").append(response); $('button[name=btnSkip]').click(function () { $.ajax({ url: "/ck/en/getcongratulationsform", type: "POST", beforeSend: function () { $("#l-loading").show(); }, success: function (response) { $("#verificationForm").hide(); $("#form-outer").append(response); $("#l-loading").hide(); } }); }); $('button[name=btnSubmitVerification]').click(function (event) { var valid = true; if ($("input[name=txtVerifyCode1]").val() == "" || $("input[name=txtVerifyCode2]").val() == "" || $("input[name=txtVerifyCode3]").val() == "" || $("input[name=txtVerifyCode4]").val() == "" || $("input[name=txtVerifyCode5]").val() == "" || $("input[name=txtVerifyCode6]").val() == "") { valid = false; $("#verifyCodeText").addClass("text-danger"); } if (!valid) { event.preventDefault(); } if (valid) { $.ajax({ url: "/ck/en/getverifycode", type: "POST", data: new FormData($('form[name=verificationform]')[0]), contentType: false, cache: false, processData: false, beforeSend: function () { $("#l-loading").show(); }, success: function (dataJS) { var data = JSON.parse(dataJS); if (data['status'] !== undefined && data['status'] === "success") { $("#verificationForm").hide(); $.ajax({ url: "/ck/en/getcongratulationsform", type: "POST", success: function (response) { $("#verificationForm").hide(); $("#form-outer").append(response); $("#l-loading").hide(); } }); } else { $("#l-loading").hide(); $("#verifyCodeText").addClass("text-danger"); } } }); } }); } }); } else { $('#l-loading').hide(); $('button[name=btnSubmit]').prop('disabled', false); if(!alert("We can't store your info now")){ window.location.reload(); } } } }); }); }); } }); var communicationChannel = $('#communication_chanel'); communicationChannel.on("change", function () { var self = $(this); var cur = self.find("option:selected"); var type = cur.attr("communication-channel-type"); $('#txtCommunicationChannelType').val(type); formVM.typeOfCommunicationChannel(type); $('input[name=txtCommunicationChannelID]').val('').parent().removeClass("has-error"); $('input[name=txtCommunicationChannelNumber]').parent().removeClass("has-error"); $('input[name=txtCommunicationChannelOther]').val('').parent().removeClass("has-error"); $('.msg-communication-channel-other').text(''); $('.msg-communication-id').text(''); $('.msg-phone-communication').text(''); }); let serviceKnow = $('#slServiceKnow'); serviceKnow.on("change", function () { let self = $(this); let cur = self.find("option:selected"); let type = cur.attr("data-know-type"); formVM.typeOfKnow(type); }); function AppViewModel() { this.typeOfCommunicationChannel = ko.observable(''); this.typeOfKnow = ko.observable(''); } var formVM = new AppViewModel(); ko.applyBindings(formVM); function emailValid(email) { 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); } $("#slCountry").change(function() { var txtPleaseSelect = ''; var country=$("#slCountry option:selected").val(); if (country == "") { $('#state').addClass('hidden'); } else { $.ajax({ type: "GET", cashe: false, url: "/ck/en/country-get-state-leadform", data: {country_code: country}, 'dataType': 'json', success: function (response) { $('#slState').val(''); if( response.code === 200 && response.message === 'success' && response.data.length > 0 ){ $('#slState').html(txtPleaseSelect + response.data); $('#state').removeClass('hidden'); } else { $('#state').addClass('hidden'); } } }); } }).trigger('change'); }); });