Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/460.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.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
如何使用javascript/jquery为web应用程序创建验证插件?_Javascript_Jquery - Fatal编程技术网

如何使用javascript/jquery为web应用程序创建验证插件?

如何使用javascript/jquery为web应用程序创建验证插件?,javascript,jquery,Javascript,Jquery,我正在尝试为web应用程序创建一个验证插件,当使用javascript/jquery将表单id传递给插件时,该插件将对表单进行评估 这是我编写的代码,其中我使用了每个字段的名称来评估html页面的输入 $(document).ready(function () { $('#formId').validate({ rules: { 'Name': { required: t

我正在尝试为web应用程序创建一个验证插件,当使用javascript/jquery将表单id传递给插件时,该插件将对表单进行评估

这是我编写的代码,其中我使用了每个字段的名称来评估html页面的输入

$(document).ready(function () {
       $('#formId').validate({
            rules: {
                    'Name': {
                        required: true,
                        minlength: 3
                    },
                    'Email': {
                        required: true,
                        minlength: 5
                    },
                    'password': "required",
                    'Confirm_password': {
                        required : true,
                        equalTo: "#password"
                    },
                    'test': {
                        required: true
                    },
                    'Radio': { required: true },

                    'ddl': {
                        required: {
                            depends: function (element) {
                                if ('none' == $('#select_field').val()) {
                                    $('#select_field').val('');
                                }
                                return true;
                            }
                        }
                    }
                  },

                messages: {
                    'Name': {
                        required: "Enter the name",
                        minlength: "The name should be atleast of 3 characters "
                    },
                    'Email': {
                        required: "Enter the emailid",
                        minlength: "The emailid should be atleast of 5 characters"
                    },

                    'test': {
                        required: "Check atleast one box"
                    },
                    'Radio':
                     {
                          required:"Please select an option<br/>"
                     },
                    'ddl':
                        {
                            required: "Please select an option from the list"
                      }
                },
                submitHandler: function (form) { 
                alert('valid form submitted'); 
                return false;
            }
            });
        });

使用Jquery验证插件


您应该添加到目前为止尝试过的内容您对验证的哪一部分有问题?任何相关的代码都是有用的。为什么不使用validate.js?这是一个有效的问题吗?具体的问题是什么?什么东西没有按预期工作?看见