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

匿名 (未验证) 提交于 2019-12-03 01:29:01

问题:

I have a page1.php and i have a fly.php. page1.php is a simple (regular) form page, where people put info, when user submit the form.

  • via ajax it loads the captcha template and ask to verify on the fly (till here is fine).
  • After onFly validation, i want to allow this .submit() continue

Question: How can i after .submit() pause for validation of this captcha and after validation successfull, resume the form submission (which is on hold)?

Example:

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

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; } 
$value = obj::getRandom(); echo ''; echo ""; ?>
*Please enter the above code below, to verify this request

Follow up (proof read):

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

回答1:

The simplest way would be to make the "submit" button not actually a button, but rather just a standard button. If validation passes, you can manually submit the forum using $('form').submit() or something similar.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!