Error occurs while validating form input using jQuery in Firebug
        Posted  
        
            by Param-Ganak
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Param-Ganak
        
        
        
        Published on 2010-04-05T08:02:08Z
        Indexed on 
            2010/04/05
            10:33 UTC
        
        
        Read the original article
        Hit count: 298
        
jQuery
|jquery-validate
I have written a custom validation code in jQuery, which is working fine. I have a login form which has two fields, i.e. userid and password. I have written a custom code for client side validation for these fields. This code is working fine and gives me proper error messages as per the situation.
But the problem with this code is that when I enter the invalid data in any or both field and press submit button of form then it displays the proper error message but at the same time when I checked it in Firebug it displays following error message when submit button of the form is clicked
validate is not defined
function onclick(event) { javascript: return validate(); }
(click clientX=473, clientY=273)
Here is the JQUERY validation code
$(document).ready(function (){ $("#id_login_form").validate({
        rules: {
                    userid: {
                                required: true,
                                minlength: 6,
                                maxlength: 20,
//                                  basic: true
                                  },
                        password: {
                                    required: true,
                                    minlength: 6,
                                    maxlength: 15,
//                                  basic: true
                                   }
                    },
            messages: {
                        userid: {
                                    required: "
 Please enter the username.",
                                    minlength: "
User Name should be minimum 6 characters long.",
                                    maxlength: "
User Name should be maximum 15 characters long.",
//                                  basic: "
working here"
                                  },
                        password: {
                                    required: "
 Please enter the password.",
                                    minlength: "
Password should be minimum 6 characters long.",
                                    maxlength: "
Password should be maximum 15 characters long.",
//                                  basic: "
working here too.",
                                  }
                  },
        errorClass: "errortext",
        errorLabelContainer: "#messagebox"
                                         }
        });
        });
/* $.validator.addMethod('username_alphanum', function (value) { return /^(?![0-9]+$)[a-zA-Z 0-9_.]+$/.test(value); }, 'User name should be alphabetic or Alphanumeric and may contain . and _.');
$.validator.addMethod('alphanum', function (value) { 
return /^(?![a-zA-Z]+$)(?![0-9]+$)[a-zA-Z 0-9]+$/.test(value); 
}, 'Password should be Alphanumeric.');
$.validator.addMethod('basic', function (value) { 
return /^[a-zA-Z 0-9_.]+$/.test(value); 
}, 'working working working');
*/
So please tell me where is I am wrong in my jQuery code. Thank You!
© Stack Overflow or respective owner