Topic: Modal closure without displaying the message
I created a login form inside the modal, but when I click on the login button, the modal closes without displaying an error or success message. I want the medal to be closed only if the login is successful, otherwise it will not be closed and will display an error message.
Modal closure without displaying the message
Your problem is related to default behavior of 'submit' in the browsers. When you submit something, the page will reload. So you need to add
e.preventDefault() to your login button in order to prevent this default behavior. Example: https://mdbootstrap.com/snippets/standard/d-wajszczuk/3230099#js-tab-view . You need to add validation to take place when the button is clicked or whenever you wish to make validation happen. You can use our validation which can be found here https://mdbootstrap.com/docs/standard/forms/validation/ or make your own. You can also trigger some behavior on certain events related to modal. More information can be found here https://mdbootstrap.com/docs/standard/components/modal/#api-section-events. You can manually close modal by using
hide() method. More information in previous link under Methods section.
Services & Consulting
Hire our experts to help you design or build a dedicated project.
- User: Pro
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 3.9.0
- Device: Desktop
- Browser: chrome
- OS: 10
- Provided sample code: No
- Provided link: No