title: Display Bootstrap Modal if the condition is true?
body: <p>I want to display the bootstrap modal on button click in ASp.net MVC if the condition is true or false.
  Say eg if I check the login credentials and if it fails then how to display the error in a bootstrap modal or bootstrap alerts.</p>
  
  <pre><code>    &lt;html&gt;
  &lt;head&gt;
      &lt;link href="~/bootstrap.min.css" rel="stylesheet" /&gt;
      &lt;script src="~/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://code.jquery.com/jquery-3.1.0.min.js"&gt;&lt;/script&gt;
  
       &lt;script&gt;
           $(function()
           {
               $("#mybutton").click(function(){
                   var test1 = $('#test').val();
                   if(test1 == "Value")
                       $("#myModal").modal('show');
               });
           });
       &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
          &lt;input type="text" class="form-control" id="test" placeholder="Enter A Value" /&gt;
          &lt;button type="submit" value="Click" name="click" id="mybutton"&gt;Click Me!&lt;/button&gt;            
  
  
      &lt;!-- Modal --&gt;
      &lt;div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"&gt;
          &lt;div class="modal-dialog" role="document"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;div class="modal-header"&gt;
                      &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
                      &lt;h4 class="modal-title" id="myModalLabel"&gt;Modal title&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
                      ...
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;
                      &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
                      &lt;button type="button" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How it can be achieved???</p>