0

以下 javascript 的第一部分适用于我想要使用它的用途(通过按钮单击导航引导选项卡)

然而,第二部分是我的表单验证,由于某种原因,如果我把那个代码放进去,它会破坏第一部分的代码。我似乎不知道为什么。任何帮助都会很棒。

<script type="text/javascript">

 ////------ Section 1 ------\\\\    
$(document).ready(function() {
    $('#myTab a').click(function (e) {
        e.preventDefault();
        $(this).tab('show');
    });

    var showPageTwo = function() {
        $('#pageSwitcher li:eq(1) a').tab('show');
    };

    var showPageThree = function() {
        $('#pageSwitcher li:eq(2) a').tab('show');
    };

    var showPageFour = function() {
        $('#pageSwitcher li:eq(3) a').tab('show');
    };

    var showPageFive = function() {
        $('#pageSwitcher li:eq(4) a').tab('show');
    };

    var showPageSix = function() {
        $('#pageSwitcher li:eq(5) a').tab('show');
    };

    var showPageSeven = function() {
        $('#pageSwitcher li:eq(6) a').tab('show');
    };

    var showPageEight = function() {
        $('#pageSwitcher li:eq(7) a').tab('show');
    };

    var showPageNine = function() {
        $('#pageSwitcher li:eq(8) a').tab('show');
    };

    $(".tab-content").on("click","#page1 button", showPageTwo);

    $(".tab-content").on("click","#page2 button", showPageThree);

    $(".tab-content").on("click","#page3 button", showPageFour);

    $(".tab-content").on("click","#page4 button", showPageFive);

    $(".tab-content").on("click","#page5 button", showPageSix);

    $(".tab-content").on("click","#page6 button", showPageSeven);

    $(".tab-content").on("click","#page7 button", showPageEight);

    $(".tab-content").on("click","#page8 button", showPageNine);

////------ Section 2 ------\\\\

    $("#appForm").validate({
        rules:{
            project_title:"required",
            country:"required",
            parish:"required",
            name_of_watercourse:"required",
            which_is_a_tributary_of:"required",
            name_of_applicant:"required",
            contact_person_or_project_supervisor:"required",
            relationship_to_organization:"required",
            business_phone:"required",
            home_phone:"required",
            email:{
                required:true,
                email:true
            },
            signature_of_thesis_or_study_supervisor:"required",
            mailing_address:"required",
            postal_code:"required",
            website:"required",
            mailing_address_for_payment:"required",
            hst_registration_no:{
                required:true,
                number:true
            },
                        total_cost_dollar:{
                required:true,
                number:true
            },
            total_cost_percent:{
                required:true,
                number:true
            },
            dollar_amount_requested_from_nbwtf:{
                required:true,
                number:true
            },
            percent_amount_requested_from_nbwtf:{
                required:true,
                number:true
            },
            descriptive_summary:"required"
            });
        });
    });
});
</script>
4

1 回答 1

1

您的代码中存在语法错误:

            });
        }); // <-- should be just `}` or maybe its one of the other ones
    });
});
</script>

当您的 JavaScript 中出现语法错误时,整个脚本块或文件不会执行。

于 2013-05-23T01:52:39.837 回答