表格确认后再提交 [英] form confirm before submit

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

问题描述

我使用的是简单表单,我想允许用户在表单提交之前进行确认...我知道使用jQuery会很容易,但是我对代码有点困惑...

I am using a simple form and I want to allow the user to confirm before the form submits... I know this would be easy using jQuery, but I am a bit confused about code...

$(function() {
  $(".testform").submit(function() {
    $('.submitbtn').text('confirm');
  });
});

我知道上面的代码还不完整,我想请您帮忙完成它,因此它将给出一个警报(使用jQuery警报),提示请确认一切是否正确"并更改提交的文本按钮以确认",而不是提交".如果用户单击再次确认,它将提交表单.我希望这是有道理的.谢谢.

I know that the above code is not complete and I would like your help to finish it, so it would give an alert (using jQuery alert) that says 'Please confirm if everything is correct' and changes the text on the submit button to "confirm" instead of "submit". If the user clicks confirm again it would submit the form. I hope this makes sense. thanks.

推荐答案

样本小提琴: http://jsfiddle.net/z68VD/

html :

<form id="uguu" action="http://google.ca">
    <input type="submit" value="text 1" />
</form>

jquery :

$("#uguu").submit(function() {
    if ($("input[type='submit']").val() == "text 1") {
        alert("Please confirm if everything is correct");
        $("input[type='submit']").val("text 2");
        return false;
    }
});

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

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