title: Trigger bootstrap modal if a condition statement is not met
body: <p>Instead of using the default jquery alert popup, I'd like to trigger a Bootstrap Modal. All the tutorials I've read, the modal is triggered by the <code>click(function(){});</code>. I'd like to have if triggered if a condition in my "if statement" is not met. Here is the code I have </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var test1 = $('#test').val();
  
  $('#go').click(function() {
    if (test1 === "") {
      alert("Please enter all values in the fields");
      $('#myModal').modal('show');
    }
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" /&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;div class="form-group"&gt;
    &lt;label for="test" class="col-sm-3 control-label"&gt;Test&lt;/label&gt;
    &lt;div class="col-sm-3"&gt;
      &lt;input type="text" class="form-control" id="test" placeholder="Enter A Value"&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
    &lt;div class="col-sm-offset-6 col-sm-3"&gt;
      &lt;button type="button" id="go" class="btn btn-primary"&gt;Go&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;!--Modal--&gt;
  &lt;div class="modal fade" id="#myModal"&gt;
    &lt;div class="modal-dialog"&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"&gt;Modal title&lt;/h4&gt;
  
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
          &lt;p&gt;One fine body&amp;hellip;&lt;/p&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;!-- /.modal-content --&gt;
    &lt;/div&gt;
    &lt;!-- /.modal-dialog --&gt;
  &lt;/div&gt;
  &lt;!-- /.modal --&gt;
  &lt;!--End Modal--&gt;</code></pre>
  </div>
  </div>
  </p>