jezzipin jezzipin - 1 year ago 119
jQuery Question

Issue with jQuery validate : TypeError: is undefined

I'm currently running the following jQuery plugin to validate all of my forms within our system.

As our html relies on css classes, I am using the following code to apply a rule to all fields that have the class .required:

required: true,
messages: {
required: "This field is required"

However, when trying this in Firefox, Firebug gives me the following error:

TypeError: is undefined

This is within the plugin itself and not my code although I believe that when my code makes a call to this plugin the plugin cannot handle the way it needs to be executed. Has anyone else encountered this error?

My form is currently a mixture of text fields, drop-down menus and radio buttons all with the same class of .required. Unfortunately I cannot change the HTML as it is dynamic and built into our underlying system (so it is generated using PL/SQL procedures).

Unfortunately I cannot post a link to the form in question as our system would require you to login however I can try and replicate it in a fiddle if the code above is not enough to go on.

Any help would be greatly appreciated.

Kind regards,

Jason Espin


If it helps, the plugin code is hot linked from here and I have not made any modifications to it:

<script src=""></script>
<script src=""></script>

Answer Source

Your each function is redundant as if the field has a class of "required" the it will have the required method applied to it as a class rule, and the default message is 'this field is required'

    //    $(this).rules('add',{
    //        required: true,
    //        messages: {
    //            required: "This field is required"
    //        }
    //    });

you can verify the 'required' rule is still applied to your fields by running this in the browser console:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download