Pages

Boostrap 5 Common code to place on layout page, then any boostrap modal on close, form data inside the modal will be cleared

<pre>
    <script>
        document.addEventListener('hidden.bs.modal', function (e) {
            var modal = e.target; // The modal that triggered the event

            // Check if the modal contains a form
            var form = modal.querySelector('form');

            if (form) {
                form.reset(); // Reset the form if a form is found
            }
        });
    </script>
    </pre>

No comments:

Post a Comment

Search This Blog