开发者

Prevent Default with formToWizard.js

开发者 https://www.devze.com 2023-01-10 06:23 出处:网络
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

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 onl开发者_StackOverflowy 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,


Sounds like you need a confirm box - see here: http://www.w3schools.com/js/js_popup.asp


@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>
0

精彩评论

暂无评论...
验证码 换一张
取 消