Validation JQuery : Uncaught TypeError: Cannot call method 'call' of undefined

jquery, jquery-validate

Solution

`messages` is a stand-alone option, but you've accidentally placed it inside of `rules`, which breaks the plugin.

It appears to work without errors when this syntax is fixed. (BTW, the code is easier to troubleshoot when it's properly indented and tabbed.)

DEMO: http://jsfiddle.net/sERPT/

$(document).ready(function () {

    $("#reg").validate({

        rules: {
            'u1[firstName]': "required",
            'u2[firstName]': "required",
            'u1[lastName]': "required",
            'u2[lastName]': "required",
            'u2[email]': "required",
            'u1[email]': {
                required: true,
                email: true,
                remote: {
                    url: '?module=auth&action=checkemail',
                    type: 'post',
                    data: {
                        'u1[email]': function () {
                            console.log($("#email1").val());
                            return $("#email1").val();
                        }
                    }
                }
            }
        },
        messages: {
            'u1[firstName]': {
                required: "My requied text"
            }
        }
    });

});

Problem

I always get error ``` Uncaught TypeError: Cannot call method 'call' of undefined ``` when I type correct email in my form. Custom massages doesn't work too. Function `?module=auth&amp;action=registration` work properly (it returns string 'false' or 'true'). I use this plugin: JQuery Validation Plugin . I think problem is in these files below. custom.validation.js: ``` $(document).ready(function() { $("#reg").validate({ rules: { 'u1[firstName]': "required", 'u2[firstName]': "required", 'u1[lastName]' : "required", 'u2[lastName]' : "required", 'u1[email]' : { "required" : true, "email" : true, "remote" : { url: '?module=auth&action=checkemail', type: "post", data: { 'u1[email]': function() { console.log($("#email1").val()); return $("#email1").val(); } } }, 'u2[email]' : "required" }, messages: { 'u1[firstName]': { required: "My requied text" } } } }); }); ``` and form: ``` <fieldset> <label for="imie" >Name:</label> <input type="text" name="u1[firstName]"{if $smarty.post.u1.firstName} value="{$smarty.post.u1.firstName}"{/if}> <label for="nazwisko" >Lastname:</label> <input type="text" name="u1[lastName]" {if $smarty.post.u1.lastName} value="{$smarty.post.u1.lastName}"{/if}> <label for="adresEmail">E-mail:</label> <input type="text" name="u1[email]" id="email1" {if $smarty.post.u1.email} value="{$smarty.post.u1.email}"{/if}> </fieldset> <fieldset> <button type="submit">Send</button> </fieldset> ```

Original source