使用jQuery确认表单提交 [英] Confirmation of Form Submission using jQuery

查看:139
本文介绍了使用jQuery确认表单提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在提交表单之前显示一个警告框.

I want to show an alert box before form submission.

如果用户按是",则该表单将提交,否则将不会提交. 有使用jQuery的解决方案吗?

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

推荐答案

您可以通过拦截html表单的commit事件来使用javascript confirm(message) : boolean函数.

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;
    } 
});

这篇关于使用jQuery确认表单提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆