Submit button doesn't run server side code

This question says it all. I have an asp.net page using jquery. first when i clicked the submit button it will show the expected object error. I ran firebug and it displayed an error in the return validate () function that was added to the ClientClick of the button.

  <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>

      

i removed it and now the submit button still doesn't work. server code is not executed. it doesn't show any errors. I can't figure out what the problem is.


I posted the code here: the expected object is jquery

+1


source to share


2 answers


EDIT: After looking at the code. The reason the form is not submitting even after removing the Validate () call on your button is because you have debug: true, this prevents the form from being submitted. Change it to debug: false and it will be posted.



 $("#form1").validate({
            debug: false,
            .....

      

+3


source


I believe your problem is that the form submission is not working because you have a javascript parsing error. You can check the Firebug console to see if there are any errors occurring while loading the page. Any JavaScript errors can disrupt the form submission process.

Looking at your previous question, I would suggest that you may not have included the validation plugin since validation is undefined. This error is still probably happening, and the rest of the javascript on the page - including any added javascript ASP.NET cannot be parsed.



Do you have a script include for the validate plugin? it would look something like this:

 <script type="text/javascript" src="..../jquery.validate.js"></script>

      

0


source







All Articles