I’m working with Bootstrap and I have a search form and a modal. I want my model to open up when I click on the search form. The modals I found online were only working with a button but I don’t want my model to open up with a button. Is there a way to make my modal work with input form?
I looked here: https://getbootstrap.com/docs/4.0/components/modal/
My search form code:
<div class="input-box">
<input type="text" class="form-control">
<i class="fa fa-search"></i>
</div>
2
Answers
The code that worked for me:
Try this below
In your search form
the most important thing is the
class="modal"
and the id of the modalid="exampleModal"
, you target the model in the input field usingdata-bs-toggle="modal" data-bs-target="#exampleModal"
classes inside thesearch form