ĐĂNG KÝ HỒ SƠ VIỆC LÀM
Cung cấp thông tin để Vieclamhot.com tìm kiếm công việc phù hợp với bạn.
Thông tin bạn cung cấp sẽ giúp Vieclamhot.com tìm kiếm và giới thiệu những cơ hội việc làm phù hợp với nghề nghiệp, kỹ năng, ngoại ngữ và quốc gia bạn mong muốn.
Đăng ký thành công!
Hồ sơ của bạn đã được ghi nhận. Vieclamhot.com sẽ liên hệ với bạn khi có công việc phù hợp.
/* ===================================================== CẤU HÌNH ===================================================== */
/* DÁN URL GOOGLE APPS SCRIPT /exec CỦA BẠN VÀO ĐÂY */
const GOOGLE_SCRIPT_URL = "https://script.google.com/macros/s/AKfycbxzhMz0zZe4BsELzWghNAB0gUaEH2Je-VpxOWza8bI9S5wshbFlyfOQX3hmd691Dxefrw/exec";
/* ===================================================== BIẾN ===================================================== */
let vlhCurrentStep = 0;
const vlhSteps = document.querySelectorAll(".vlh-step");
const vlhProgress = document.querySelectorAll(".vlh-progress-item");
/* ===================================================== HIỂN THỊ STEP ===================================================== */
function vlhShowStep(step) {
vlhSteps.forEach(function(item, index) {
item.classList.toggle( "active", index === step );
});
vlhProgress.forEach(function(item, index) {
item.classList.toggle( "active", index <= step ); }); const formBox = document.querySelector(".vlh-form-box"); if (formBox) { window.scrollTo({ top: formBox.getBoundingClientRect().top + window.scrollY - 20, behavior: "smooth" }); } } /* ===================================================== NEXT ===================================================== */ function vlhNext() { if (!vlhValidateCurrentStep()) { return; } if ( vlhCurrentStep < vlhSteps.length - 1 ) { vlhCurrentStep++; vlhShowStep( vlhCurrentStep ); } } /* ===================================================== PREVIOUS ===================================================== */ function vlhPrev() { if (vlhCurrentStep > 0) {
vlhCurrentStep--;
vlhShowStep( vlhCurrentStep );
}
}
/* ===================================================== VALIDATE ===================================================== */
function vlhValidateCurrentStep() {
/* STEP 1 */
if (vlhCurrentStep === 0) {
let valid = true;
const fullname = document.getElementById( "vlh_fullname" );
const phone = document.getElementById( "vlh_phone" );
const birthday = document.getElementById( "vlh_birthday" );
const province = document.getElementById( "vlh_province" );
if (!fullname.value.trim()) {
showError("error_fullname");
valid = false;
} else {
hideError("error_fullname");
}
const phoneClean = phone.value.replace(/\D/g, "");
if ( !/^0\d{9}$/.test(phoneClean) ) {
showError("error_phone");
valid = false;
} else {
hideError("error_phone");
}
if (!birthday.value) {
showError("error_birthday");
valid = false;
} else {
hideError("error_birthday");
}
if (!province.value) {
showError("error_province");
valid = false;
} else {
hideError("error_province");
}
const gender = document.querySelector( 'input[name="vlh_gender"]:checked' );
if (!gender) {
showError("error_gender");
valid = false;
} else {
hideError("error_gender");
}
return valid;
}
/* STEP 2 */
if (vlhCurrentStep === 1) {
let valid = true;
const education = document.querySelector( 'input[name="vlh_education"]:checked' );
const experience = document.querySelector( 'input[name="vlh_experience"]:checked' );
if (!education) {
showError("error_education");
valid = false;
} else {
hideError("error_education");
}
if (!experience) {
showError("error_experience");
valid = false;
} else {
hideError("error_experience");
}
return valid;
}
/* STEP 3 */
if (vlhCurrentStep === 2) {
return true;
}
/* STEP 4 */
if (vlhCurrentStep === 3) {
return true;
}
/* STEP 5 */
if (vlhCurrentStep === 4) {
let valid = true;
const countries = document.querySelectorAll( 'input[name="vlh_country"]:checked' );
const jobs = document.querySelectorAll( 'input[name="vlh_job"]:checked' );
if ( countries.length === 0 ) {
showError("error_country");
valid = false;
} else {
hideError("error_country");
}
if ( jobs.length === 0 ) {
showError("error_job");
valid = false;
} else {
hideError("error_job");
}
return valid;
}
return true;
}
/* ===================================================== ERROR ===================================================== */
function showError(id) {
const element = document.getElementById(id);
if (element) {
element.classList.add("show");
}
}
function hideError(id) {
const element = document.getElementById(id);
if (element) {
element.classList.remove("show");
}
}
/* ===================================================== LANGUAGE ===================================================== */
function vlhLanguageToggle(language) {
const checkbox = document.getElementById( "lang_" + language );
const level = document.getElementById( "level_" + language );
if (!checkbox || !level) { return; }
if (checkbox.checked) {
level.style.display = "block";
} else {
level.style.display = "none";
}
}
/* ===================================================== GIỚI HẠN QUỐC GIA = 3 ===================================================== */
document .querySelectorAll( 'input[name="vlh_country"]' ) .forEach(function(checkbox) {
checkbox.addEventListener( "change", function() {
const checked = document.querySelectorAll( 'input[name="vlh_country"]:checked' );
if (checked.length > 3) {
this.checked = false;
alert( "Bạn chỉ có thể chọn tối đa 3 quốc gia." );
}
} );
});
/* ===================================================== GIỚI HẠN NGHỀ = 3 ===================================================== */
document .querySelectorAll( 'input[name="vlh_job"]' ) .forEach(function(checkbox) {
checkbox.addEventListener( "change", function() {
const checked = document.querySelectorAll( 'input[name="vlh_job"]:checked' );
if (checked.length > 3) {
this.checked = false;
alert( "Bạn chỉ có thể chọn tối đa 3 công việc." );
}
} );
});
/* ===================================================== CHỈ CHO CHỌN 1 TRONG CÁC NGÔN NGỮ "CHƯA BIẾT NGOẠI NGỮ" ===================================================== */
const noneLanguage = document.getElementById( "lang_none" );
if (noneLanguage) {
noneLanguage.addEventListener( "change", function() {
if (this.checked) {
document .querySelectorAll( 'input[name="vlh_language"]:not(#lang_none)' ) .forEach(function(item) {
item.checked = false;
const id = item.id.replace( "lang_", "" );
const level = document.getElementById( "level_" + id );
if (level) { level.style.display = "none"; }
});
}
} );
}
/* ===================================================== NẾU CHỌN NGOẠI NGỮ THÌ BỎ CHỌN "CHƯA BIẾT" ===================================================== */
document .querySelectorAll( 'input[name="vlh_language"]:not(#lang_none)' ) .forEach(function(item) {
item.addEventListener( "change", function() {
if (this.checked && noneLanguage) {
noneLanguage.checked = false;
}
} );
});
/* ===================================================== CHARACTER COUNTER ===================================================== */
const experienceDetail = document.getElementById( "vlh_experience_detail" );
if (experienceDetail) {
experienceDetail.addEventListener( "input", function() {
document.getElementById( "experience_counter" ).textContent = this.value.length;
} );
}
/* ===================================================== LẤY CHECKBOX ===================================================== */
function vlhGetChecked(name) {
return Array.from( document.querySelectorAll( 'input[name="' + name + '"]:checked' ) ).map(function(item) {
return item.value;
});
}
/* ===================================================== LẤY RADIO ===================================================== */
function vlhGetRadio(name) {
const item = document.querySelector( 'input[name="' + name + '"]:checked' );
return item ? item.value : "";
}
/* ===================================================== UTM ===================================================== */
function vlhGetUTM() {
const params = new URLSearchParams( window.location.search );
return {
utm_source: params.get("utm_source") || "",
utm_medium: params.get("utm_medium") || "",
utm_campaign: params.get("utm_campaign") || "",
utm_term: params.get("utm_term") || "",
utm_content: params.get("utm_content") || ""
};
}
/* ===================================================== SUBMIT ===================================================== */
async function vlhSubmit() {
const consent = document.getElementById( "vlh_consent" );
if (!consent.checked) {
showError( "error_consent" );
return;
}
hideError( "error_consent" );
const submitButton = document.getElementById( "vlh_submit_button" );
const loading = document.getElementById( "vlh_loading" );
submitButton.disabled = true;
submitButton.textContent = "Đang gửi...";
loading.style.display = "block";
const utm = vlhGetUTM();
/* ================================================= TẠO DATA ================================================= */
const data = {
fullname: document.getElementById( "vlh_fullname" ).value.trim(),
phone: document.getElementById( "vlh_phone" ).value.trim(),
email: document.getElementById( "vlh_email" ).value.trim(),
birthday: document.getElementById( "vlh_birthday" ).value,
gender: vlhGetRadio( "vlh_gender" ),
province: document.getElementById( "vlh_province" ).value,
education: vlhGetRadio( "vlh_education" ),
major: document.getElementById( "vlh_major" ).value.trim(),
certificate: document.getElementById( "vlh_certificate" ).value,
experience: vlhGetRadio( "vlh_experience" ),
experience_detail: document.getElementById( "vlh_experience_detail" ).value.trim(),
skills: vlhGetChecked( "vlh_skills" ),
languages: vlhGetChecked( "vlh_language" ),
japanese_level: document.getElementById( "vlh_japanese_level" ).value,
korean_level: document.getElementById( "vlh_korean_level" ).value,
english_level: document.getElementById( "vlh_english_level" ).value,
chinese_level: document.getElementById( "vlh_chinese_level" ).value,
german_level: document.getElementById( "vlh_german_level" ).value,
countries: vlhGetChecked( "vlh_country" ),
jobs: vlhGetChecked( "vlh_job" ),
available: document.getElementById( "vlh_available" ).value,
salary: document.getElementById( "vlh_salary" ).value,
source: document.getElementById( "vlh_source" ).value,
utm_source: utm.utm_source,
utm_medium: utm.utm_medium,
utm_campaign: utm.utm_campaign,
utm_term: utm.utm_term,
utm_content: utm.utm_content,
landing_page: window.location.href,
page_url: window.location.href
};
/* ================================================= KIỂM TRA URL ================================================= */
if ( !GOOGLE_SCRIPT_URL || GOOGLE_SCRIPT_URL.includes( "DAN_URL_GOOGLE" ) ) {
alert( "Bạn chưa cấu hình URL Google Apps Script." );
submitButton.disabled = false;
submitButton.textContent = "ĐĂNG KÝ HỒ SƠ";
loading.style.display = "none";
return;
}
/* ================================================= GỬI GOOGLE SHEET ================================================= */
try {
const response = await fetch( GOOGLE_SCRIPT_URL, {
method: "POST",
body: JSON.stringify(data)
} );
const result = await response.json();
console.log( "Google Apps Script:", result );
if ( result && result.success ) {
/* Ẩn các step */
vlhSteps.forEach( function(step) {
step.style.display = "none";
} );
document .querySelector( ".vlh-progress" ) .style.display = "none";
/* Hiện thành công */
document .getElementById( "vlh_success" ) .style.display = "block";
/* Hiển thị Lead ID */
document .getElementById( "vlh_lead_id" ) .textContent = "Mã hồ sơ: " + result.lead_id;
/* Scroll */
window.scrollTo({
top: document .querySelector( ".vlh-form-box" ) .getBoundingClientRect() .top + window.scrollY - 20,
behavior: "smooth"
});
} else {
throw new Error( result?.message || "Không nhận được phản hồi hợp lệ." );
}
} catch (error) {
console.error( "Submit error:", error );
alert( "Không thể gửi hồ sơ. " + "Vui lòng thử lại sau." );
submitButton.disabled = false;
submitButton.textContent = "ĐĂNG KÝ HỒ SƠ";
loading.style.display = "none";
}
}
/* ===================================================== KHỞI TẠO ===================================================== */
vlhShowStep(0);