vishnu reji
vishnu reji

Reputation: 398

How to prevent close of a bootstrap modal after submitting the form?

I am using a Bootstrap modal window for a form. I need to prevent the modal from closing after pressing the submit button. I need to close the modal only after clicking the close button. Please help me.

  <!--Login, Signup, Forgot Password Modal -->
    <div id="login-signup-modal" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">

    <!-- login modal content -->
    <div class="modal-content" id="login-modal-content">

    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title"><span class="glyphicon glyphicon-lock"></span> Login Now!</h4>
  </div>

    <div class="modal-body">
      <form method="post" id="Login-Form" role="form">

        <div class="form-group">
            <div class="input-group">
            <input name="email" id="email" type="email" class="form-control input-lg" placeholder="Enter Email" required data-parsley-type="email" >
            </div>                      
        </div>


        <div class="form-group">
            <div class="input-group">
            <input name="password" id="login-password" type="password" class="form-control input-lg" placeholder="Enter Password" required data-parsley-length="[6, 10]" data-parsley-trigger="keyup">
            </div>                      
        </div>

        <div class="checkbox">
          <label><input type="checkbox" value="" checked>Remember me</label>
        </div>
          <button type="submit" class="btn btn-success btn-block btn-lg">LOGIN</button>
      </form>
    </div>

    <div class="modal-footer">
      <p>
      <a id="FPModal" href="javascript:void(0)">Forgot Password?</a> | 
      <a id="signupModal" href="javascript:void(0)">Register Here!</a>
      </p>
    </div>

   </div>

Upvotes: 1

Views: 4530

Answers (1)

subir biswas
subir biswas

Reputation: 396

Try this code to see if you can prevent the dialog from submit

$( "form" ).submit(function( event ) { 
  event.preventDefault();
});

And then close it using close button.

Upvotes: 1

Related Questions