link cheng

document.addEventListener(“DOMContentLoaded”, function() { var bookingBtn = document.querySelector(“.o-header__booking-btns a[href=’https://hwc.wuyuanweb.com/reservation/’]”); if (bookingBtn) { bookingBtn.href = “https://new.link/reservation/”; // 將此處更改為新連結 } var remoteConsultationBtn = document.querySelector(“.o-header__booking-btns a[href=’https://hwc.wuyuanweb.com/remote-consultation/’]”); if (remoteConsultationBtn) { remoteConsultationBtn.href = “https://new.link/remote-consultation/”; // 將此處更改為新連結 } });Continue reading

JetFormBuilder – Redirect after page submit

document.addEventListener(‘DOMContentLoaded’, function() { // Replace ‘your-form-class’ with the actual class of your JetFormBuilder form const forms = document.querySelectorAll(‘.jet-form-builder’); forms.forEach(function(form) { form.addEventListener(‘submit’, function(event) { // Set a flag in local storage to indicate that the form was submitted localStorage.setItem(‘formSubmitted’, ‘true’); });…Continue reading

Jetformbuilder – Parse Repeater on Review Page

jQuery(() => { const { addFilter, addAction } = JetPlugins.hooks; const { Filter } = JetFormBuilderAbstract; function RepeaterFilter() { Filter.call(this); this.getSlug = function () { return ‘repeaterTemplate’; }; /** * @param value {ObservableRow[]} */ this.apply = function (value) { const…Continue reading

JetFormBuilder – Submit Loader

document.addEventListener(‘DOMContentLoaded’, function() { var form = document.querySelector(‘.jet-form-builder’); if (form) { form.addEventListener(‘submit’, function(event) { var loader = document.getElementById(‘formLoader’); if (loader) { loader.style.display = ‘block’; } }); document.addEventListener(‘jet-form-builder/ajax/success’, function(event) { var loader = document.getElementById(‘formLoader’); if (loader) { loader.style.display = ‘none’; } });…Continue reading

JetFormBuilder – Extra Validation

jQuery(document).ready(function() { // Function to validate the form function customValidateForm() { let isValid = true; // Iterate over form fields and validate jQuery(‘.jet-form-builder .jet-form-builder__field’).each(function() { if (!jQuery(this).val()) { isValid = false; jQuery(this).addClass(‘error’); // Add an error class to invalid fields…Continue reading

JetFormBuilder – Masks Number Input Field

document.addEventListener(‘DOMContentLoaded’, function() { function formatCurrency(input) { var number = parseFloat(input.replace(/,/g, ”)); if (!isNaN(number)) { return number.toLocaleString(‘en-US’, { style: ‘currency’, currency: ‘USD’, minimumFractionDigits: 0, maximumFractionDigits: 0 }); } else { alert(‘Please enter a valid number.’); return ”; } } function handleBlur(event)…Continue reading

Progress Bar Javascript

// progress-bar.js document.addEventListener(‘DOMContentLoaded’, function() { document.querySelectorAll(‘.bar-group’).forEach(function(bar) { const range = parseInt(bar.getAttribute(‘data-range’), 10); const current = parseInt(bar.getAttribute(‘data-current’), 10); const percentage = (current / range) * 100; bar.querySelector(‘.progress-fill’).style.width = percentage + ‘%’; }); });Continue reading

Colour Switch – Sync with Device Colour Scheme

// Function to apply the color scheme function applyColorScheme(scheme) { if (scheme === ‘dark’) { document.documentElement.classList.add(“us-color-scheme-on”); document.querySelector(‘input[name=”us-color-scheme-switch”]’).checked = true; } else { document.documentElement.classList.remove(“us-color-scheme-on”); document.querySelector(‘input[name=”us-color-scheme-switch”]’).checked = false; } } // Detect the preferred color scheme const prefersDarkScheme = window.matchMedia(“(prefers-color-scheme: dark)”).matches; if…Continue reading