(function($) { // We use a MutationObserver to catch the form as soon as 365Villas injects it const observer = new MutationObserver(function(mutations, obs) { const phoneField = $('#transaction_add_phone_home'); if (phoneField.length) { // 1. Force the system-required attributes phoneField.addClass('required').attr('alt', 'required'); // 2. Add visual 'required' indicator phoneField.attr('placeholder', 'Phone (Primary) *'); // 3. Attach a secondary 'fail-safe' validation to the submit button $('#reservation_proceed_button').on('click', function(e) { if (phoneField.val().trim() === "") { // Highlight the field if empty phoneField.css('border', '2px solid #ff0000'); phoneField.focus(); // Show the system's own error container if it exists $('#transaction_update_error').text('Please provide a primary phone number.').show(); e.stopImmediatePropagation(); return false; } }); // Once the field is found and modified, we can stop observing obs.disconnect(); } }); observer.observe(document.documentElement, { childList: true, subtree: true }); })(jQuery);