开发者

Confirmation of Form Submission using jQuery

开发者 https://www.devze.com 2023-03-14 18:52 出处:网络
I want to show an ale开发者_开发百科rt box before form submission. If a user presses yes, then the form will submit, otherwise it wont.

I want to show an ale开发者_开发百科rt box before form submission.

If a user presses yes, then the form will submit, otherwise it wont. Is there a solution using jQuery?


you can use the javascript confirm(message) : boolean function by intercepting the submit event of html form.

$("#html_form").submit(function(e){
    if (!confirm("should i really submit"))
    {
        e.preventDefault();
        return;
    } 
});


$('#yourform').submit(function(e) {
    if(!confirm('really submit the form?')) {
        e.preventDefault();
        return;
    }
    // submit the form via ajax, e.g. via the forms plugin
    // http://jquery.malsup.com/form/
});


Read this post...

Confirmation Posts Yes/No Submit

May be this will help you out.

0

精彩评论

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