Object expected - jquery

I am getting an "Object expected" error for some odd reason due to jquery and this is not "submitting" the form or entering data into the database.

without jquery, data can be entered into the database. but now it is not.

I have used jquery mainly for validating asp.net controls.


roosteronacid, the checks work fine and the id property is the same too. submit just doesn't execute the server-side code and I can't figure out what the problem is.

EDIT:

this is the 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>

      

Is there something wrong with the code?

it says object expected on 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;
        }

      

the jquery code displays all errors in the correct places, but after fixing it, it doesn't send data.

plugin I am using:

http://bassistance.de/jquery-plugins/jquery-plugin-validation/

+1


source to share


6 answers


An expected object occurs when you try to access an object that is undefined, unmentioned, or is mistakenly typed. Check which object is expected. Use Firefox firebug to debug your javascript or debug with IE to get an object that the runtime can't find.



+8


source


I solved this problem by accessing the jQuery file correctly. I had it in a subdirectory and didn't have the right path.



+2


source


answer here: submit button doesn't issue server-side code

'debug' must be set to false.

+1


source


I am guessing the error is in using the jQuery validation plugin. Try to test only one ASP.NET control. This will make it easier to spot the error:

$("#form1").validate({
    rules: {
       id_of_control_you_know_exists_in_the_rendered_html: {
            required: true,
            minlength: 2
        }
    }
});

      

Another possibility might be that you are using ASP.NET controls in a custom control. In this case, the id property of the rendered HTML control is different from what you set in your .aspx page.

0


source


I had the same problem but on our staging server. A comparison of the files showed that they were the same and there was no problem to place the same files on different sites, so it had to be the specific site where we put the files. The fault after troubleshooting was that we set the Footer.html parameter in the properties for the website in IIS, so the server injected it inside the script into rendering. Therefore choosing any good compatible code. We have disabled the footer property in the IIS setup - bingo!

0


source


I am also facing this problem. but in my case i was jquery version of prob. I installed the latest version and it works in IE.

0


source







All Articles