UrbanPro
true

Learn .NET MVC from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Clear boostrap modal on hide or close

Dorababu Meka
06/09/2018 0 0

When I am working with MVC project I had a requirement like to clear all the errors and text entered inside a bootstrap modal. So that when I opened the modal again I could see a plain binding.

$("#myModal").on("hidden.bs.modal", function () {  

        $("#guest_form input[type='text'],input[type='password']").val('');  
        $("#guest_form input[type='text'],input[type='password']").each(function () {  
            $(this).removeClass('form-control input-validation-error');  
            $(this).addClass("form-control");  
        });  
        $(".field-validation-error").text('');  
    }); 

Initially my modal looks as follows

 

On submitting the modal without entering any data here my modal looks as follows

On closing the modal and opening it again I am still seeing the errors on my modal

What I need is I would like to clear all the validations and the classes which got applied using MVC validations so that it should again show me the original screen as follows

Try the above code and give a try, which will clear all the errors and entered text when you close and open the modal again . If you are facing any issues let me know.
 
Happy Coding :)
0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Steps to fill drop-down value from database to view page in ASP.Net MVC Application
In simple few steps you can fill the dynamic data from database to HTML page in MVC Application Write connection string in web config file Create table related getter setter in model Fetch data...

Difference between Abstract Class and Interface
This is probably one of the most commonly asked questions in any job interview for .Net. Before we look into the differences between the two lets find out the main features. Abstract Class By definition...

Asp.net MVC Application LifeCycle
Any web application has two main execution steps first understanding the request and depending on the type of the request sending out appropriate response. MVC life cycle also follow same principle. MVC...

jquery Menu by me
How to make Mobile Menu in JQuery?

Mark And Sweep Algorithm in Javascript Memory Management
This algorithm reduces the definition of "an object is not needed anymore" to "an object is unreachable". This algorithm assumes the knowledge of a set of objects called roots (In JavaScript, the root...
X

Looking for .NET MVC Classes?

The best tutors for .NET MVC Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn .NET MVC with the Best Tutors

The best Tutors for .NET MVC Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more