Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery表单验证不起作用/插件_Jquery_Html_Validation - Fatal编程技术网

jQuery表单验证不起作用/插件

jQuery表单验证不起作用/插件,jquery,html,validation,Jquery,Html,Validation,我无法使jQuery验证工作。它实际上在一个在线编译器中工作,所以我怀疑我没有正确地插入它。代码如下: $(document).ready(function () { $('#CustSubmitForm').validate({ rules: { CustId: { required: true, minlength: 2 }, Pay

我无法使jQuery验证工作。它实际上在一个在线编译器中工作,所以我怀疑我没有正确地插入它。代码如下:

$(document).ready(function () {
    $('#CustSubmitForm').validate({
        rules: {
            CustId: {
                required: true,
                minlength: 2
            },
            PaymentSum: {
                required: true,
                number: true,
                minlength: 5
            }
        },

        messages: {
            CustId: "Enter valid ID",
            PaymentSum: "Enter valid sum"
        }
    });
});
这些是我包含的脚本:

src="/Scripts/jquery-1.8.2.js"
src="/Scripts/jquery.validate.js"

有人能回答问题的原因吗?多谢各位

幸运的是,我找到了答案。问题是BundleConfig中有一个“~/bundles/jqueryval”)绑定器。默认情况下,Jquery验证包含在中。因此,要使验证工作正常,需要将其插入布局页面:@Scripts.Render(“~/bundles/jqueryval”)

幸运的是,我找到了答案。问题是BundleConfig中有一个“~/bundles/jqueryval”)绑定器。默认情况下,Jquery验证包含在中。因此,要使验证工作正常,需要将其插入布局页面:@Scripts.Render(“~/bundles/jqueryval”)