' + state.text + ''); } $(document).ready(function(){ $('#communication_chanel').select2({ templateResult: formatState, templateSelection: formatState, dropdownCssClass: "communication-dropdown" }); var profileTel = $('input[name=txtPhone]'); profileTel.intlTelInput({ autoPlaceholder: "off", initialCountry: "vn", preferredCountries: ["vn"], formatOnDisplay: true, utilsScript: "https://d32q3bqti6sa3p.cloudfront.net/shared/js/utils.js" }); profileTel.intlTelInput('setNumber',''); var isValidNumber = true; profileTel.blur(function() { var phone_number = profileTel.intlTelInput('getNumber'); $('input[name=txt_phone_number]').val(phone_number); isValidNumber = profileTel.intlTelInput('isValidNumber'); var country_data = profileTel.intlTelInput('getSelectedCountryData'); $('input[name=txt_iso2]').val(country_data.iso2); $('input[name=txtCommunicationChannelNumber]').val(profileTel.val()); $('input[name=txtPhoneNumberCommunicationChannel]').val(phone_number); $('input[name=txtPhoneIso2CommunicationChannel]').val(country_data.iso2); communicationChannelNumber.intlTelInput('destroy').intlTelInput({ initialCountry: country_data.iso2, formatOnDisplay: false }); }); var communicationChannelNumber = $('input[name=txtCommunicationChannelNumber]'); communicationChannelNumber.intlTelInput({ autoPlaceholder: "off", initialCountry: "vn", preferredCountries: ["vn"], formatOnDisplay: true, utilsScript: "https://d32q3bqti6sa3p.cloudfront.net/shared/js/utils.js" }); communicationChannelNumber.intlTelInput('setNumber', ''); var isValidCommunicationChannelNumber = true; communicationChannelNumber.blur(function () { if (formVM.typeOfCommunicationChannel() != 'Phone') { return; } var phone_number = communicationChannelNumber.intlTelInput('getNumber'); $('input[name=txtPhoneNumberCommunicationChannel]').val(phone_number); isValidCommunicationChannelNumber = communicationChannelNumber.intlTelInput('isValidNumber'); var country_data = communicationChannelNumber.intlTelInput('getSelectedCountryData'); $('input[name=txtPhoneIso2CommunicationChannel]').val(country_data.iso2); }); var arrayFileUpload = []; $("input[id='txtAttachFile']").change(function (e) { arrayFileUpload = []; $('#nameFiles').empty(); $('#textChoosen').text('Không có tập tin nào được chọn'); var files = e.target.files; if (files.length > 0) { $('#textChoosen').text(''); for (var i = 0; i < files.length; i++) { var name = files[i].name; var ext = name.split('.').pop().toLowerCase(); var size = files[i].size; arrayFileUpload.push([name, ext, size]); $('#nameFiles').append((i+1)+'. '+name+'
'); } } }); $('button[name=btnApply]').click(function (event) { var valid = true; if ($('#communication_chanel').val() == 0) { valid = false; $('.msg-communication-channel').text('Vui lòng chọn kênh liên lạc'); $('#communication_chanel').parent().addClass("has-error"); } else { $('.msg-communication-channel').text(''); $('#communication_chanel').parent().removeClass("has-error"); } if($('input[name=txtName]').val() == ''){ valid = false; $('.msg-name').text('Vui lòng nhập Họ và Tên'); $('input[name=txtName]').parent().addClass("has-error"); } else{ $('.msg-name').text(''); $('input[name=txtName]').parent().removeClass("has-error"); } if($('input[name=txtEmail]').val() == ''){ valid = false; $('.msg-email').text('Vui lòng nhập email'); $('input[name=txtEmail]').parent().addClass("has-error"); }else if( !emailValid($('input[name=txtEmail]').val()) ){ valid = false; $('.msg-email').text('Email không đúng'); $('input[name=txtEmail]').parent().addClass("has-error"); } else{ $('.msg-email').text(''); $('input[name=txtEmail]').parent().removeClass("has-error"); } if ($('input[name=txtPhone]').val() == ''){ valid = false; $('.msg-phone').text('Vui lòng nhập số điện thoại'); $('input[name=txtPhone]').parent().addClass("has-error"); } else if (!isValidNumber){ valid = false; $('.msg-phone').text('Số điện thoại không đúng'); $('input[name=txtPhone]').parent().addClass("has-error"); } else { $('.msg-phone').text(''); $('input[name=txtPhone]').parent().removeClass("has-error"); } if ($('select[name=slcRole]').val() == 0) { $('.msg-career').text('Chọn 1 tùy chọn'); $('#slcRole').parent().addClass("has-error"); valid = false; } else { $('.msg-career').text(''); $('#slcRole').parent().removeClass("has-error"); } if(arrayFileUpload.length>0) { $.each(arrayFileUpload, function(key, val) { if(arrayFileUpload.length>3) { valid = false; $('.msg-file').text('Vui lòng chọn giới hạn 3 tệp.'); } else if(val[2] > 20971520) { valid = false; $('.msg-file').text('Vui lòng chọn kích thước tệp giới hạn 20MB!'); } else if ($.inArray(val[1], acceptUploadCVExts) === -1) { valid = false; $('.msg-file').text('Vui lòng chọn đúng định dạng tệp.'); } else { $('.msg-file').text(''); } }); } else { valid = false; $('.msg-file').text('Vui lòng chọn một tệp.'); } if (formVM.typeOfCommunicationChannel() == 'Phone') { if ($('input[name=txtCommunicationChannelNumber]').val() == '') { valid = false; $('.msg-phone-communication').text('Vui lòng nhập số điện thoại'); $('input[name=txtCommunicationChannelNumber]').parent().addClass("has-error"); } else if (!isValidCommunicationChannelNumber) { valid = false; $('.msg-phone-communication').text('Số điện thoại không đúng'); $('input[name=txtCommunicationChannelNumber]').parent().addClass("has-error"); } else { $('.msg-phone-communication').text(''); $('input[name=txtCommunicationChannelNumber]').parent().removeClass("has-error"); } } if (formVM.typeOfCommunicationChannel() == 'Text') { if ($('input[name=txtCommunicationChannelID]').val() == '') { valid = false; $('.msg-communication-id').text('Vui lòng nhập ID'); $('input[name=txtCommunicationChannelID]').parent().addClass("has-error"); } else { $('.msg-communication-id').text(''); $('input[name=txtCommunicationChannelID]').parent().removeClass("has-error"); } } if (formVM.typeOfCommunicationChannel() == 'Other') { if ($('input[name=txtCommunicationChannelID]').val() == '') { valid = false; $('.msg-communication-id').text('Vui lòng nhập ID'); $('input[name=txtCommunicationChannelID]').parent().addClass("has-error"); } else { $('.msg-communication-id').text(''); $('input[name=txtCommunicationChannelID]').parent().removeClass("has-error"); } if ($('input[name=txtCommunicationChannelOther]').val() == '') { valid = false; $('.msg-communication-channel-other').text('Vui lòng nhập kênh khác'); $('input[name=txtCommunicationChannelOther]').parent().addClass("has-error"); } else { $('.msg-communication-channel-other').text(''); $('input[name=txtCommunicationChannelOther]').parent().removeClass("has-error"); } } if (!valid){ event.preventDefault(); } if(valid) { var recapchaSiteKeyV3 = "6LdWirgZAAAAADQLMRas899PdUB_rHw3SDh4rWwk"; grecaptcha.ready(function() { grecaptcha.execute(recapchaSiteKeyV3, {action:'validate_captcha'}).then(function(token) { $('#formApplyCV').prepend(''); var url = "/apply-cv"; $.ajax({ type: "POST", url: url, data: new FormData($('form[name=formApplyCV]')[0]), contentType: false, cache: false, processData:false, beforeSend: function() { $('#l-loading').show(); $('button[name=btnApply]').prop('disabled', true); }, success: function(dataJS){ var data = JSON.parse(dataJS); $(".apply-box").remove(); if(data['status'] !== undefined && data['status']==="success"){ $('form[name=formApplyCV]').hide(); $('#l-loading').hide(); $( ".modal-body" ).append("