jQuery Validation Plugin:“无法读取未定义的属性'调用'”noSpace

时间:2016-09-07 18:09:14

标签: jquery jquery-validate

jQuery验证插件的新手,无法弄清楚这个TypeError:

这是我的HTML:

<input name="clusterName" type="text" id="clusterName" />

以下是我的jquery的相关部分:

    $(document).ready(function() {
    $('#cloudBuilderForm').validate({

    rules: {
        clusterName: {
            required: true,
            noSpace: true
        },
        keyPair: {
            required: true,
            noSpace: true
        },
        volumeSize: {
            required: true,
            range:[256, 1024]
        }
    },
    messages: {
        clusterName: {
            required: "Provide cluster name",
            noSpace: "Cannot contain spaces"
        },
        keyPair: {
            required: "Provide valid key-pair",
            noSpace: "Cannot contain spaces"
        },
        volumeSize: {
            required: "Provide a volume size",
            range: "Must be between 256 & 1024"
        }
    },

    highlight: function(element, errorClass) {
        $(element).siblings('span').hide();
    }

    });

    $('#cloudBuilderSubmit').click(function() {
        $('#cloudBuilderForm').valid();
    });
});

我还包括

jquery.validate.min.js
additional-methods.min.js
按顺序

以下是完整错误:

jquery.validate.min.js:4 Uncaught TypeError: Cannot read property 'call' of undefined.  Exception occurred when checking element clusterName, check the 'noSpace' method.

1 个答案:

答案 0 :(得分:0)

要为可能找到它的其他人留下这个。谷歌搜索告诉我使用“noSpace”规则。实际上,规则是“nowhitespace”。希望这有助于其他人