使用 formToWizard.js 防止默认

发布于 2024-09-13 09:46:41 字数 712 浏览 6 评论 0原文

我有一个表单向导,需要阻止用户从步骤 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橙味迷妹 2024-09-20 09:46:41

听起来您需要一个确认框 - 请参阅此处: 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

草莓味的萝莉 2024-09-20 09:46:41

@Nick Craver - 谢谢伙计。

<script type="text/javascript">
    $("#step0Next").live('click', function(event) {
        $('#step1Prev').click();  //go back to step 1
        if($('#RT').is(':checked') && !$('.ex').is(':checked')) {
            if(!confirm("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?")) return;
            $('#step0Next').die('click');
        }
    $(this).triggerHandler('click');
    });
</script>

@Nick Craver - thanks man.

<script type="text/javascript">
    $("#step0Next").live('click', function(event) {
        $('#step1Prev').click();  //go back to step 1
        if($('#RT').is(':checked') && !$('.ex').is(':checked')) {
            if(!confirm("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?")) return;
            $('#step0Next').die('click');
        }
    $(this).triggerHandler('click');
    });
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文