开发者

jQuery timeout function after validation

开发者 https://www.devze.com 2023-03-29 17:06 出处:网络
I use this function to validate my form: <script type=\"text/javascript\"> $(document).ready(function() {

I use this function to validate my form:

<script type="text/javascript">
$(document).ready(function() {
$('#tracks_form').validate({ 
        submitHandler: function(form) {

            form.submit(); 
        }
    })
 });
<开发者_开发问答;/script>

What I need is to create a timeout function inside this one.

so, as soon as the form has been validated, it will stop the page for about 2-3 seconds and THEN will finally submit the form.

How do I modify this function to achieve this result?

Thank you so much!


You can use setTimeout to delay the form submit

$(document).ready(function() {
    $('#tracks_form').validate({ 
        submitHandler: function(form) {
           setTimeout(function(){
             form.submit(); 
           }, 3000);//Time in milliseconds
        }
    })
 });
0

精彩评论

暂无评论...
验证码 换一张
取 消