如何暂停表单提交,1最后确认,在最后,之后释放/触发/继续提交? [英] How to pause form submit, for 1 last validation, at the very end and after that release/trigger/continue the submission?
问题描述
我有一个page1.php中我有一个fly.php。 page1.php中是一个简单的(常规)表单页面,在这里人们把信息,当用户提交表单。
- 通过AJAX加载验证码模板,并要求核实飞(到这里是罚款)。
- 在onFly验证之后,我想允许这种.submit()继续
问:如何.submit()暂停验证准则后
n这个验证码和验证全成后,恢复表单提交(即保留)?
例如:
第1部分:page1.php中
$(文件)。就绪(函数()
{
$('。callmeback)。递交(函数()
{
$阿贾克斯({
键入:GET,
网址:/include/class/fly.php
数据:A = B,
异步:假的,
beforeSend:函数()
{
$(document.body的).find删除()(blackwindow。')。
$(document.body的).find('NOSPAM。)删除()。
},
完成:函数()
{
},
成功:函数(MSG)
{
$(document.body的).append(MSG);
$('。blackwindow')。的CSS({
不透明:0.90
});
$('。NOSPAM')。找到('输入[类型=按钮])。住(点击,函数()
{
//最终验证
VAR安全= $('NOSPAM。)找到('#安全)VAL()。
。VAR随机= $('。NOSPAM)找到('#随机)VAL()。
如果(随机!=安全)
{
警报(无效的验证码。');
返回false;
} 其他 {
//基本上它的第二次?并返回true?
}
});
}
});
//返回false;
});
});
<形式方法= POST操作= thanks.php类=callmeback>
<输入类型=文本值= 100.00 NAME =量/>
<输入类型=提交值=提交名称=提交/>
< /形式GT;
第2部分:fly.php
&LT ;? require_once'obj.php';?>
.blackwindow {
位置:固定;
顶部:0px;
左:0px;
宽度:100%;
高度:100%;
的z-index:1000;
背景颜色:#000000;
}
.nospam {
位置:固定;
顶部:30%;
左:30%;
填充:12px的;
边框:实心的3px#686868;
背景色:#FFFFFF;
的z-index:1001;
}
< DIV CLASS =blackwindow>< / DIV>
< DIV CLASS =NOSPAM>
< DIV>
&LT ;?
$值= OBJ :: getRandom();
回声'< IMG SRC =包括/班/ return_img.php数='$的价值。/>';
回声<输入类型=隐藏ID =随机NAME =随机值=$值'/>中;
?>
< DIV>
*请输入上面的code以下,以验证此请求< BR />
<输入类型=文本级=文本框ID =安全NAME =安全/>
< / DIV>
< / DIV>
< DIV>
<输入类型=按钮的名称= myButton的值=验证/>
< / DIV>
< / DIV>
跟进(校对):
$(文件)。就绪(函数()
{
$('。callmeback')。找到('输入[类型=按钮])。住(点击,函数()
{
$阿贾克斯({
键入:GET,
网址:/include/class/fly.php
数据:A = B,
异步:假的,
beforeSend:函数()
{
$(document.body的).find删除()(blackwindow。')。
$(document.body的).find('NOSPAM。)删除()。
},
完成:函数()
{
},
成功:函数(MSG)
{
$(document.body的).append(MSG);
$('。blackwindow')。的CSS({
不透明:0.90
});
$('。NOSPAM')。找到('输入[类型=按钮])。住(点击,函数()
{
//最终验证
VAR安全= $('NOSPAM。)找到('#安全)VAL()。
。VAR随机= $('。NOSPAM)找到('#随机)VAL()。
如果(随机!=安全)
{
警报(无效的验证码。');
返回false;
} 其他 {
$('。callmeback)提交()。
}
});
}
});
//返回false;
});
});
最简单的方法是使提交按钮,并不是一个真正的<输入类型=提交>
按钮,而只是一个标准的按钮
。如果验证通过,则可以使用手动提交论坛 $(形式)。提交()
或类似的东西。
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 validatio
n 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;
});
});
<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>
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;
});
});
The simplest way would be to make the "submit" button not actually a <input type='submit'>
button, but rather just a standard button
. If validation passes, you can manually submit the forum using $('form').submit()
or something similar.
这篇关于如何暂停表单提交,1最后确认,在最后,之后释放/触发/继续提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!