成功提交后让对话框开始工作
我试图让我的表单在成功提交表单后显示一个对话框(可能通过 Javascript)。我该怎么做?
JS
<script type="text/javascript">
$.validator.setDefaults({
});
$().ready(function() {
// validate alphaRegister form on keyup and submit
$("#alphaRegister").validate({
rules: {
email: {
required: true,
email: true
}
},
messages: {
email: "*"
}
});
});
</script>
HTML
<form id="alphaRegister" action="src/php/newSubscriber.php" method="post">
<input type="email" name="email" id="cemail" value="" class="required" />
<div style="float:right; margin:0 5px 2px 0;"><input type="submit" id="submit" name="submit" value="" /></div>
</form>
I am trying to make my form display a dialog box (possibly via Javascript) upon successful submission of my form. How do I do this?
JS
<script type="text/javascript">
$.validator.setDefaults({
});
$().ready(function() {
// validate alphaRegister form on keyup and submit
$("#alphaRegister").validate({
rules: {
email: {
required: true,
email: true
}
},
messages: {
email: "*"
}
});
});
</script>
HTML
<form id="alphaRegister" action="src/php/newSubscriber.php" method="post">
<input type="email" name="email" id="cemail" value="" class="required" />
<div style="float:right; margin:0 5px 2px 0;"><input type="submit" id="submit" name="submit" value="" /></div>
</form>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
提交/处理表单后,使用服务器端脚本将 JS 变量添加到页面,然后在
$().ready
函数中检查该变量是否已设置。如果是,则显示您的对话框。更新:
为此,您需要将 PHP 变量
formSubmitResult
设置为 true/false 或 1/0(如果它通过/未通过 PHP 验证例程)。然后将其放在您提交的页面的头部:
Use your server side script to add a JS variable to your page once the form has been submited/processed and then in your
$().ready
function, check to see if this variable is set. If it is then display your dialog box.Update:
To do this you will need to set a PHP variable
formSubmitResult
to true/false or 1/0 if it passes/fails your PHP validation routine.Then put this in the head of the page that you submit to: