jquery验证& id的ft号码

时间:2012-02-07 10:42:00

标签: jquery jquery-validate

您好我有一张表格,它使用salesforce中的各种数字,例如:

Landing Page:<input  id="00NF0000008Mrcm" maxlength="40" name="00NF0000008Mrcm" size="20" type="text" /><br>

这是我的jquery:

$("#requestInfo").validate({
    rules: {
        first_name: {
            required: true
        },
        last_name: {
            required: true
        },
        email: {
            required: true,
            email: true
        },
        '00NF0000008Mrcm': {
            selectNone: true
        }

    },
    messages: {
        first_name: 'Please enter your first name',
        last_name: 'Please enter your last name',
        email: 'Please enter your email address',
        00NF0000008Mrcm: 'Please enter your telephone number'
    }
});

但是这些字段在控制台上的firebug中出现错误,并且在重命名验证js中的规则和html中的id工作时最终不会验证,但是因为它来自salesforce(外部引导脚本) )它生成代码,它不会进入引导系统,我怎样才能使代码验证?

以下是控制台错误:invalid property id [Break On This Error] 00NF0000008Mrcm: { selectNone: true }

谢谢

1 个答案:

答案 0 :(得分:0)

尝试以不同的方式添加规则:

// first setup the normal validation
$("#requestInfo").validate({
    rules: {
        first_name: {
            required: true
        },
        last_name: {
            required: true
        },
        email: {
            required: true,
            email: true
        }

    },
    messages: {
        first_name: 'Please enter your first name',
        last_name: 'Please enter your last name',
        email: 'Please enter your email address'
    }
});
// then add your custom id based validation
$("#00NF0000008Mrcm").rules("add", {
    selectNone: true,
    messages: {
        selectNone: 'Please enter your telephone number'
    }
});

此处的演示演示:http://jsfiddle.net/manseuk/JpsxY/