Topic: Clear Modal Form On Close
                                            
                                            andy@ipower.uk.com
                                     pro  premium  priority                                     asked 6 years ago                                
Hello, I have a modal form based on the examples, when a user partially completes the form but presses cancel to close the modal the modal is not cleared, the next time the modal is opened the old content remains - i have tried various methods to clear the modal etc but i cant get any to work - i wonder if someone could suggest a method perhaps using js
                                                    
                                                    Mateusz Łubianka
                                             staff                                             answered 6 years ago                                        
Try to use hide.bs.modal function. This event is fired immediately when the hide instance method has been called.
More info about it:  https://mdbootstrap.com/docs/jquery/modals/basic/#options
$('#myModal').on('hidden.bs.modal', function (e) {
    $('#yourForm').find("input[type=text], textarea").val("");
})
Best,
andy@ipower.uk.com pro premium priority commented 6 years ago
Great, Thank you so much
Mateusz Łubianka staff commented 6 years ago
I'm glad everything works
Best,
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Pro
 - Premium support: No
 - Technology: MDB jQuery
 - MDB Version: 4.13.0
 - Device: Windows 10
 - Browser: All
 - OS: WIndows 10
 - Provided sample code: No
 - Provided link: No