return false is not working in my submit click

Posted by kumar on Stack Overflow See other posts from Stack Overflow or by kumar
Published on 2010-06-06T17:46:22Z Indexed on 2010/06/06 17:52 UTC
Read the original article Hit count: 248

Filed under:

Hello friends.

this is the code i am using for my Html.BeginForm..

 $('#PbtnSubmit').click(function() {
            $('#PricingEditExceptions input[name=PMchk]').each(function() {
                if ($("#PricingEditExceptions input:checkbox:checked").length > 0) {
                    var checked = $('#PricingEditExceptions input[type=checkbox]:checked');
                    var PMstrIDs = checked.map(function() {
                        return $(this).val();
                    }).get().join(',');
                    $('#1_exceptiontypes').attr('value', exceptiontypes)
                    $('#1_PMstrIDs').attr('value', PMstrIDs);
                } else {
                    alert("Please select atleast one exception");
                    return false;
                }
            });
        });

in else blcok my return false is not working after alert mesage also its going to my controler?

thanks is this right?

i tried like this

 $('#PbtnSubmit').click(function() {
                $('#PricingEditExceptions input[name=PMchk]').each(function() {
                    if ($("#PricingEditExceptions input:checkbox:checked").length > 0) {
                        var checked = $('#PricingEditExceptions input[type=checkbox]:checked');
                        var PMstrIDs = checked.map(function() {
                            return $(this).val();
                        }).get().join(',');
                        $('#1_exceptiontypes').attr('value', exceptiontypes)
                        $('#1_PMstrIDs').attr('value', PMstrIDs);
                    } else {
                        alert("Please select atleast one exception");

                    }
                });
return false;
            });

if i do like this on submit its doing nothing..

thanks

© Stack Overflow or respective owner

Related posts about jQuery