Jquery验证:错误$ .validator.methods [method]未定义

时间:2014-12-20 11:05:35

标签: javascript jquery html twitter-bootstrap validation

点击提交按钮时,我收到Jquery错误 $。validator.methods [方法]未定义

实际上,我正在验证两个字段中的一个字段。

我们正在使用以下库文件进行验证: a)jquery.validate.1.9.0.js, b)jquery-validate.bootstrap-tooltip.js

我的HTML代码:

<form name="addRewards" id="addRewards" action="" method="post">
    <input type="hidden" name="programType" id="programType" value="<?php echo $programDetail->program_type;?>" />
    <div class="profile-row-h-view">

        <label class="add_h_view"><strong>Add:</strong></label>
        <div class="gen-option">
            <input type="radio" disabled="disabled" value="points" <?php if($programDetail->program_type=="pointtype"){echo "checked";}?> name="pType" > <label for="gen1"> Points</label>
        </div>
        <!-- gen option ends -->
        <div class="gen-option">
            <input type="radio" disabled="disabled" <?php if($programDetail->program_type=="punchtype"){echo "checked";}?> value="punches" name="pType" > <label for="gen2"> Punches</label>
        </div>
        <!-- gen option ends -->

        <input type="text" maxlength="3" name="addNumber" id="addNumber" class="small_txt_history mygroup" value="" />

    </div>

    <div class="profile-row-h-view">
        <label>Add Reward :</label>
        <div class="select-options">
            <select id="offers" name="offers" class="mygroup">
                <option value="">Select Offer</option>
                <option value="">20% discount on Sheets</option>
                <option value="">30% discount on Pillows</option>
            </select>
        </div>
        <!-- Select options Ends -->
    </div>

    <div class="opt-buttons clear">
        <input type="submit" name="addPoints" id="addPoints" class="opt-btn-save" value="Add">

    </div>
</form>

验证代码:

$("#addRewards").validate({
    rules: {
        addNumber : {
            number: true,
            require_from_group: [1, '.mygroup']
        },
        offers : {
            number: true,
            require_from_group: [1, '.mygroup']
        }
    },
    groups: {
        theGroup: 'addNumber offers'
    },
    tooltip_options: {
        addNumber: {placement:'right',html:false},
        offers: {placement:'right',html:false}
    },
    highlight: function (element) { // hightlight error inputs

    },

    success: function (label) {

    },

    errorPlacement: function (error, element) {
        error.addClass('help-small no-left-padding').insertAfter(element.closest('.input-icon'));
    },

    submitHandler: function (form) {
        addPointsPunches();
    }
}); 

请提出建议,以便我们解决此问题。

0 个答案:

没有答案