使用 formToWizard.js 防止默认
我有一个表单向导,需要阻止用户从步骤 1 移动到步骤 2。通过验证来完成此操作很容易,但这不是必需的,只是在选中某些框组合时发出警告。我已经让它工作到了一定程度,不幸的是,它不会阻止用户从步骤 1 移动到步骤 2,并在步骤 2 上显示警报。理想情况下,它会在步骤 1 上显示警报/确认对话框,并且只允许用户如果他们选择“确定”,请转到步骤 2,选择“取消”将关闭框并保留在该页面上。有人可以帮忙吗?非常感谢。现在,代码如下:
$("#step0Next").live('click', function(event) {
if($("#RT").is(":checked") && !$(".ex").is(':checked')) {
alert("You have not selected any exchanges for which to receive real time market data from. If
you continue, you will only receive real time data for market metrics and ten minute delayed
data for everything else. Do you wish to continue?");
$(this).die('click');
}
});
因此,如果用户选中“#RT”并且没有选中 .ex 类的框,则会转到步骤 2 并显示警报。我将用自定义 jConfirm 框替换警报。 谢谢,
I have a form wizard and need to block the user from moving from step 1 to step 2. It's easy enough to do this with validation, but this isn't a requirement, just a warning if a certain combination of boxes is checked. I have it working to a point, unfortunately it doesn't stop the user from moving from step 1 to step 2 and displays the alert on step 2. Ideally it would display the alert/confirm dialogue on step one and only allow the user to go to step 2 if they select ok, selecting cancel would close box and remain on that page. Can anyone help out here? Much appreciated. And now, the code:
$("#step0Next").live('click', function(event) {
if($("#RT").is(":checked") && !$(".ex").is(':checked')) {
alert("You have not selected any exchanges for which to receive real time market data from. If
you continue, you will only receive real time data for market metrics and ten minute delayed
data for everything else. Do you wish to continue?");
$(this).die('click');
}
});
so if a user checks "#RT" and no boxes with a class of .ex are checked, it goes to step 2 and displays the alert. I will replace alert with custom jConfirm box.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您需要一个确认框 - 请参阅此处: http://www.w3schools.com/js /js_popup.asp
Sounds like you need a confirm box - see here: http://www.w3schools.com/js/js_popup.asp
@Nick Craver - 谢谢伙计。
@Nick Craver - thanks man.