'); $('form[name=register-form]').append(''); $('form[name=register-form]').append(''); $('form[name=register-form]').append(''); $('form[name=register-form]').append(''); $('form[name=register-form]').append(''); $('form[name=register-form]').append(''); $('form[name=register-form]').append(''); $('form[name=register-form]').append(''); $('form[name=register-form]').append(''); $('form[name=register-form]').append(''); var recapchaKey = window.GLOBAL_VARIABLES.recaptchaSitekey; grecaptcha.enterprise.ready(function() { grecaptcha.enterprise.execute(recapchaKey, { action: 'validate_captcha' }).then(function(token) { $('#l-loading').show().css({"z-index": 9999}); $('button[name=btnCreateaccount]').prop('disabled', true); const formData = {}; $('form[name=register-form]') .serializeArray() .forEach(function (field) { formData[field.name] = field.value; }); formData['g-recaptcha-response'] = token; $.ajax({ url: "/km/en/login?action=register", method: 'POST', data: {...formData, txtEmail: $('input[name=rg_email]').val(), txtPassword: $('input[name=rg_password]').val(), txtCPassword: $('input[name=rg_CPassword]').val()}, success: function (response) { console.log("response", response); const dataResponse = JSON.parse(response); $('#l-loading').hide(); $('button[name=btnCreateaccount]').prop('disabled', false); const communicationChannelID = $('#txtCommunicationChannelID'); const communicationChannelNumber = $('#txtCommunicationChannelNumber'); const msgErrorRegCommunicationChannelNumber = $('#msgErrorRegCommunicationChannelNumber'); const communicationChannel = $('#slcCommunicationChannel'); const communicationChannelOther = $('#txtCommunicationChannelOther'); const communicationChannelTypePhone = $('#communicationChannelTypePhone'); if (dataResponse?.isAuth) { window.location.reload(); return; } for (const field in dataResponse.messages) { switch (field) { case 'email': $(`.msg-${field}`).text(dataResponse.messages[field]); $('input[name=rg_email]').parent().addClass("has-error"); break; case 'name': $(`.msg-${field}`).text(dataResponse.messages[field]); $('input[name=txtName]').parent().addClass("has-error"); break; case 'password': $('.msg-pass').text(dataResponse.messages[field]); $('input[name=rg_password]').parent().addClass("has-error"); break; case 'phone': $('.msg-phone').text(dataResponse.messages[field]); $('input[name=txtPhone]').parent().addClass("has-error"); break; case 'address-country': $('.msg-address-country').text(dataResponse.messages[field]); $('#slcAddressCountry]').parent().addClass("has-error"); break; case 'address': $('.msg-address').text(dataResponse.messages[field]); $('input[name=txtAddress]').parent().addClass("has-error"); break; case 'communicationChannelNumber': $('#msgErrorRegCommunicationChannelNumber').text(dataResponse.messages[field]); $('#txtCommunicationChannelNumber').addClass("has-error"); break; case 'communicationChannel': $('#msgErrorRegCommunicationChannel').text(dataResponse.messages[field]); $('#slcCommunicationChannel').addClass("has-error"); break; case 'communicationChannelOther': $('#msgErrorRegCommunicationChannelNumber').text(dataResponse.messages[field]); $('#txtCommunicationChannelOther').addClass("has-error"); break; case 'captcha': $("#mgs-error-login").text(dataResponse.messages[field]).show(); break; } } }, error: function (xhr, status, error) { $('#l-loading').hide(); $('button[name=btnCreateaccount]').prop('disabled', false); } }); }); }); } }); $( "input[name=rg_password]" ).keypress(function(e) { var s = String.fromCharCode( e.which ); if ( s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey ) { $( ".warning-capslock" ).show(); } else { $( ".warning-capslock" ).hide(); } }); communicationChannelNumber.intlTelInput({ initialCountry: "", utilsScript: "https://d19ocbwhar60hv.cloudfront.net/shared/js/utils.js", }); communicationChannelNumber.intlTelInput("setNumber", ""); }); });