JQuery验证在IE8中不起作用 [英] JQuery Validation doesn't work in IE8

查看:109
本文介绍了JQuery验证在IE8中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I used a JQuery Validation script for validating an HTML Form. This worked perfectly in Firefox but doesn't work in IE8. I think there is issue with colon(;) or semi-colon(,)... but I am unable to catch it.

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
            }
        }
    });
});


推荐答案

这两项:

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

应该是:

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

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

You're right to think the , issue, a trailing comma in a property list is what'll break IE but usually squeak by in other browsers.

这篇关于JQuery验证在IE8中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆