0

次のJavaScriptの最初のセクションは、私がそれを使用したいものに対してうまく機能します(ボタンをクリックしてブートストラップタブをナビゲートします)

ただし、2 番目のセクションはフォームの検証であり、何らかの理由でそのコードを入力すると、セクション 1 のコードが壊れてしまいます。理由がわかりません。どんな助けでも素晴らしいでしょう。

<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 に答える