如何暂停表单提交,最后一次验证,在最后和之后释放/触发/继续提交

How to pause form submit, for 1 last validation, at the very end and after that release/trigger/continue the submission?

本文关键字:提交 最后 之后 释放 触发 继续 验证 何暂停 暂停 最后一次 表单提交      更新时间:2023-09-26

我有一个page1.php和我有一个fly.php。php是一个简单的(常规的)表单页面,当用户提交表单时,人们在这里放置信息。

  • 通过ajax加载captcha模板并要求在飞行中验证(直到这里是好的)。在onFly验证之后,我想允许这个。submit()继续

问题:此验证码的How can i after .submit() pause for validatio n验证成功后,恢复表单提交(这是暂停)?

的例子:

Part 1: page1.php

$(document).ready(function()
{
 $('.callmeback').submit(function()
 {
    $.ajax({
        type    : "GET",
        url     : "/include/class/fly.php",
        data    : "a=b",
        async   : false,
        beforeSend: function()
        {
            $(document.body).find('.blackwindow').remove();
            $(document.body).find('.nospam').remove();  
        },  
        complete: function()
        {
        },      
        success : function(msg)
        {
           $(document.body).append(msg);
           $('.blackwindow').css({
              'opacity':'0.90'
           });
           $('.nospam').find('input[type="button"]').live("click", function()
           {
              // final validation
              var security= $('.nospam').find('#security').val();
              var random  = $('.nospam').find('#random').val();
                  if (random!=security)
              { 
            alert ('Invalid captcha.');
            return false;
               } else  {
            // Basically its second time? and return true?                      
               }
           });
        }
    });
    //return false;
 });
});
<form method=post action=thanks.php class="callmeback">
<input type=text value=100.00 name=amount />
<input type=submit value=submit name=submit />
</form>

Part 2: fly.php

<? require_once 'obj.php';?>
.blackwindow {
        position:fixed;
        top:0px;
        left:0px;
        width:100%;
        height:100%;
        z-index:1000;
        background-color:#000000;
}
.nospam {
        position:fixed;
        top:30%;
        left:30%;
        padding:12px;
        border:solid 3px #686868;
        background-color:#ffffff;
        z-index:1001;
}
<div class="blackwindow"></div>
<div class="nospam">
<div>
<?
$value = obj::getRandom();                                          
echo '<img src="include/class/return_img.php?number=' . $value . '" />';
echo "<input type='hidden' id='random' name='random' value='$value' />";
?>     
<div>
*Please enter the above code below, to verify this request <br/>
<input type="text" class="textbox" id="security" name="security" />
</div>
</div>
<div>
<input type=button name=mybutton value="Verify" />
</div>
</div>

跟进(校对):

$(document).ready(function()
{
 $('.callmeback').find('input[type="button"]').live("click", function()
 {
    $.ajax({
        type    : "GET",
        url     : "/include/class/fly.php",
        data    : "a=b",
        async   : false,
        beforeSend: function()
        {
            $(document.body).find('.blackwindow').remove();
            $(document.body).find('.nospam').remove();  
        },  
        complete: function()
        {
        },      
        success : function(msg)
        {
           $(document.body).append(msg);
           $('.blackwindow').css({
              'opacity':'0.90'
           });
           $('.nospam').find('input[type="button"]').live("click", function()
           {
              // final validation
              var security= $('.nospam').find('#security').val();
              var random  = $('.nospam').find('#random').val();
                  if (random!=security)
              { 
            alert ('Invalid captcha.');
            return false;
               } else  {
            $('.callmeback').submit();                      
               }
           });
        }
    });
    //return false;
 });
});

最简单的方法是使"提交"按钮实际上不是<input type='submit'>按钮,而是标准的button按钮。如果验证通过,您可以使用$('form').submit()或类似的东西手动提交论坛。