JQuery验证在IE8中不起作用

时间:2010-09-15 22:08:15

标签: jquery internet-explorer-8 jquery-validate

我使用JQuery Validation脚本验证HTML表单。 这在Firefox中完美运行但在IE8中不起作用。 我认为冒号(;)或分号(,)有问题......但是我无法抓住它。

jQuery.validator.addMethod("selectNone", function (value, element) {
    if (element.value == "") {
        return false;
    } else return true;
}, "Please select an option.");

$(document).ready(function () {
    $("#formElem").validate({
        rules: {
            Category: { // "required",simple rule, converted to {required:true}
                selectNone: true
            },
            Repair_technician: { // "required",simple rule, converted to         {required:true}
                selectNone: true
            },
            Rework_technician: { // "required",simple rule, converted to     {required:true}
                selectNone: true
            },
            Approved_by: { // "required",simple rule, converted to {required:true}
                required: true,
            },
            Part_code: {
                required: true,
            },
            Part_value: {
                required: true,
            },
            JOB_Number: { // "required",simple rule, converted to {required:true}
                required: true,
                minlength: 9,
                maxlength: 9
            }
        }
    });
});

1 个答案:

答案 0 :(得分:8)

这两个:

        Part_code: {
            required: true,
        },
        Part_value: {
            required: true,
        },

应该是:

        Part_code: {
            required: true
        },
        Part_value: {
            required: true
        },

你认为,问题是正确的,一个属性列表中的尾随逗号会破坏IE,但通常会在其他浏览器中发出吱吱声。