# Bootstrap Modal pops up with no reason

**URL:** <https://forum.djangoproject.com/t/bootstrap-modal-pops-up-with-no-reason/23340>\
**Category:** Mystery Errors\
**Created:** [August 24, 2023, 11:38am UTC](https://forum.djangoproject.com/t/bootstrap-modal-pops-up-with-no-reason/23340 "2023-08-24T11:38:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [August 24, 2023, 11:38am UTC](https://forum.djangoproject.com/t/bootstrap-modal-pops-up-with-no-reason/23340/1 "2023-08-24T11:38:56Z")

</div>

Hi there,

today I discovered a strange thing. I am almost done with my project and doing last improvements…or at least i try to 😛

Today, i wanted to implement some html-patterns for input validation within my `django-filters` filter-definitions.Like so (for example):

```auto
    employments__percent = django_filters.NumberFilter(
                                    field_name='employments__percent',
                                    lookup_expr='icontains',
                                    widget=forms.TextInput(attrs={
                                        'pattern': '^((100)|(\d{0,2}))$',
                                    }))

```

If i do so and insert not-RegEx-matching text in the field on the rendered page, than - together with the RegEx warning, which is popping up under the input field, a bootstrap-modal shows up when i click the submit-button! The Modal is also part of the page, but has nothing to do with the input field i am coding on…and no, there are no identical HTML id’s and if i remove the `pattern` part from the `attrs` brackets, the mystery is gone…

Someone any ideas what’s going on here ?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 24, 2023, 1:26pm UTC](https://forum.djangoproject.com/t/bootstrap-modal-pops-up-with-no-reason/23340/2 "2023-08-24T13:26:32Z")

</div>

It seems to me that there would have to be _some_ kind of “css selector” overlap or conflict between the two.

You may need to examine the rendered html in the browser to follow the chain of events, along with (possibly) single-stepping the JavaScript in the browser.

---

<div class="post-metadata">

**Author:** ![doc1977](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/doc1977/32/13416_2.png) [@doc1977](https://forum.djangoproject.com/u/doc1977)\
**Post date:** [September 3, 2023, 11:03am UTC](https://forum.djangoproject.com/t/bootstrap-modal-pops-up-with-no-reason/23340/3 "2023-09-03T11:03:51Z")

</div>

It gets me crazy, I don’t get it why this is happening and I still haven’t found any cross-linking between the events. I dond’t think that i have to single-step javascript, because the javascript is really simple:

```auto
<script>
    const btn = document.getElementById('customQueryButton');
    if(btn) {
        document.getElementById("customQueryButton").addEventListener("click", function () {
            let openModalCheckbox = document.getElementById("export_toggle2");
            if (openModalCheckbox.checked) {
                $('#QueryModal').modal('show');
            }
        });
    }
</script>

```

But i don’t get why the `openModalCheckbox` var is considered checked only because a regex error is triggered…
