我有一个表单向导,需要阻止用户从第1步移动到第2步。使用验证很容易做到这一点,但这不是必需的,只是警告如果某个盒子的组合是检查。我让它工作到一定程度,遗憾的是它不会阻止用户从步骤1移动到步骤2并在步骤2显示警报。理想情况下,它会在第一步显示警报/确认对话框,并且只允许用户如果他们选择确定,请转到步骤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框替换alert。 谢谢,
答案 0 :(得分:0)
听起来你需要一个确认框 - 见这里:http://www.w3schools.com/js/js_popup.asp
答案 1 :(得分:0)
@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>