预期对象-jQuery [英] object expected - jquery

查看:95
本文介绍了预期对象-jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于jquery,由于某种奇怪的原因,我收到一个错误期望对象",并且这不会提交"表单或将数据输入数据库.

i'm getting an error 'Object expected' for some odd reason due to jquery, and this does not 'submit' the form or enter the data into database.

如果没有jquery,则可以将数据输入数据库.但现在没有.

without jquery, the data could be entered into the database. but now it doesn't.

我主要使用jquery来验证asp.net控件.

i've used jquery mainly for validating asp.net controls.

roosteronacid,验证工作正常且id属性也相同.提交只是不执行服务器端代码,我无法弄清楚问题出在哪里.

roosteronacid, the validations are working perfectly fine and the id property is also the same. the submit is just not executing the server-side code and i cannot figure out what is the problem.

这是jquery代码:

this is jquery code:

 <script type="text/javascript">
        $(document).ready(function() {
            // add custom validation methods
            $.validator.addMethod('phone', function(value, el, params) {
                return this.optional(el) || /^[0-9,+,(), ,]{1,}(,[0-9]+){0,}$/.test(value);
            }, 'Please enter a valid phone number');

            $.validator.addMethod('numbers', function(value, el, params) {
                return this.optional(el) || /^[0-9]+$/.test(value);
            }, 'Invalid entry. Only Numeric is allowed.');


            $.validator.addMethod('domainurl', function(value, el, params) {
                return this.optional(el) || /^(http\:\/\/(?:www\.)?[a-zA-Z0-9]+(?:(?:\-|_)[a-zA-Z0-9]+)*(?:\.[a-zA-Z0-9]+(?:(?:\-|_)[a-zA-Z0-9]+)*)*\.[a-zA-Z]{2,4}(?:\/)?)$/.test(value);
            }, 'Please enter a valid domain url');


            $.validator.addMethod('selectone', function(value, element) {
                return this.optional(element) || (value.indexOf("none") == -1);
            }, 'Please select an option.');



            $("#form1").validate({
                debug: true,
                rules: {
                    txt_name: {
                        required: true,
                        minlength: 2
                    },
                    txt_cmp: {
                        required: true,
                        minlength: 2
                    },
                    txt_tel1: {
                        phone: true,
                        required: true,
                        minlength: 3

                    },
                    txt_tel2: {
                        phone: true,
                        required: false,
                        minlength: 3

                    },
                    txt_mob: {
                        phone: true,
                        required: false,
                        minlength: 9

                    },
                    txt_email: {
                        required: true,
                        email: true
                    },

                    txt_domname: {
                        required: true,
                        domainurl: true
                    },

                    radiobt_domain: "required",

                    ddl_yremail: {
                        required: true,
                        selectone: true
                    },
                    ddl_email: {
                        required: true,
                        selectone: true
                    },

                    txt_space: {
                        required: true,
                        numbers: true

                    },
                    txt_calfr: {
                        required: true
                    },
                    txt_calto: {
                        required: true
                    }  


            },
            messages: {
                txt_name: {
                    required: "This field is required",
                    minLength: "Please enter a valid name"
                },
                txt_cmp: {
                    required: "This field is required",
                    minLength: "Please enter a valid commpany name"
                },
                txt_tel1: {
                    required: "This field is required",
                    minLength: "Please enter a valid telephone number"

                },
                txt_tel2: {
                    minLength: "Please enter a valid telephone number"
                },
                txt_mob: {
                    minLength: "Please enter a valid mobile number"

                },
                txt_email: {
                    email: "Please enter a valid email address",
                    required: "This field is required"
                },

                txt_domname: {
                    required: "This field is required"
                },
                radiobt_domain: "Select the Hosting Type"
            }

        });
    });
    </script>

代码有什么问题吗?

它表示预期在第559行出现的对象.我检查了jquery.validate.js文件,这是它显示的代码:

it says object expected at line 559. i checked the jquery.validate.js file and this is the code it shows:

addWrapper: function(toToggle) {
            if ( this.settings.wrapper )
                toToggle = toToggle.add( toToggle.parents( this.settings.wrapper ) );
            return toToggle;
        }

jquery代码会在正确的位置显示所有错误,但是一旦更正,就不会提交数据.

the jquery code displays all the errors at the right places, but once corrected, it doesn't submit the data.

我正在使用的插件:

http://bassistance.de/jquery-plugins/jquery-plugin-验证/

推荐答案

当您尝试访问未定义,未引用或错误拼写的对象时,将出现预期的对象.找出期望的对象.使用Firefox firebug调试您的JavaScript或使用IE进行调试,以获取运行时无法找到的对象.

Object expected occur when you try to access object which is not defined, not referenced or mistakenly misspelled. Check out which object is expected. Use Firefox firebug to debug your javascript or make debugging with IE on to get hold of an object which runtime is not able to find....

这篇关于预期对象-jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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