document.addEventListener('DOMContentLoaded', function () { const dateField = document.querySelector('#my-date input'); if (!dateField) return; const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; dateField.addEventListener('change', function () { const raw = this.value; // yyyy-mm-dd if (!raw) return; const parts = raw.split('-'); if (parts.length !== 3) return; const [year, month, day] = parts; const monthName = monthNames[parseInt(month, 10) - 1]; // Format: 12 February 2026 const ukFormatted = ${parseInt(day, 10)} ${monthName} ${year}; // Show the UK format to the user this.setAttribute('data-uk-date', ukFormatted); this.placeholder = ukFormatted; // Keep the real value for form submission this.value = raw; }); });

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

One Response

Leave a Reply to A WordPress Commenter Cancel reply

Your email address will not be published. Required fields are marked *