Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Modal closure without displaying the message

mravandoust free asked 3 years ago


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.


Dawid Wajszczuk staff commented 3 years ago

Hi. Without your code I can't see opportunity to help you. So please create a snippet showing your issue https://mdbootstrap.com/snippets/ .


mravandoust free commented 3 years ago

https://mdbootstrap.com/snippets/standard/mravandoust/3228676


Dawid Wajszczuk staff answered 3 years ago


Hi,

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.

Keep coding,
Dawid


mravandoust free commented 3 years ago

Thank you for your reply


mravandoust free answered 3 years ago


Modal closure without displaying the message



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 3.9.0
  • Device: Desktop
  • Browser: chrome
  • OS: 10
  • Provided sample code: No
  • Provided link: No
Tags