Modal display when submitting a form

6

How do I display a modal the moment I submit a registration form? The content of this modal is only a message. The following happens, in this form a file and information is sent. Since it usually takes a few seconds for the upload to take place, I'd like to launch a modal with a "Please Wait" message, so the user does not change the page while uploading. There is currently no information being displayed.

    
asked by anonymous 25.07.2015 / 21:32

2 answers

1

If you are using jquery you can use:

$("form").submit(function(e){
        //Ação para abrir o modal
});

As soon as the button is clicked it will display the modal and as soon as the post is done the page will be updated to the form's action.

    
27.07.2015 / 21:55
0

I think you're going to use a loading Gif . Well, you can use it in Jquery (Ajax), like the example below:

//Este código fica após o Success e Error do Ajax
beforeSend: function () {
  $('.loader').css({ display: "block" });
},
  complete: function () {
  $('.loader').css({ display: "none" });
}
/*estilos para gif de loading*/
.loader {
    display: none;
}

.loader.show {
    display: block;
    position: fixed;
    z-index: 100;
    background-color: rgba(0, 0, 0, 1);
    background-repeat: no-repeat;
    background-position: center;
    left: 0;
    bottom: 0;
    right: 0;
    top: 0;
    }

.loading {
    width: 50px;
    height: 57px;
    position: absolute;
    top: 50%;
    left: 50%;
}

#overlay {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.64);
    opacity: 0.8;
    filter: alpha(opacity=80);
}
<div class="loader" id="overlay">
  <img src="~/Images/loading-image.gif" id="loading" class="loading" alt="loading" title="Aguarde..." />
</div>
    
20.04.2017 / 00:59