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

AJAX Grid Search (single grid)

document.addEventListener(‘DOMContentLoaded’, function () { const searchInput = document.querySelector(‘#gridSearch input[type=”text”]’); const searchForm = document.querySelector(‘#gridSearch form’); // Adjust if your search is within a form const gridResults = document.querySelector(‘.grid-results’); // The container that will display search results // Disable form submission to…Continue reading

AJAX Grid Search (multiple grids)

document.addEventListener(‘DOMContentLoaded’, function () { const searchInput = document.querySelector(‘#gridSearch input[type=”text”]’); const searchForm = document.querySelector(‘#gridSearch form’); // Adjust if your search is within a form const initialGrid = document.querySelector(‘.initial-grid’); // The initial content to hide when searching const gridResults = document.querySelector(‘.grid-results’); //…Continue reading