4

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

2
  • Have you tried passing the full URL and not just the query string? Commented Mar 25, 2013 at 19:39
  • Your posted HTML does not match your jQuery. Where are the u2 fields? Also, would be better to post the rendered HTML as that's the only thing the client-side code it going to see/use. Commented Mar 25, 2013 at 22:00

1 Answer 1

3

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"
            }
        }
    });

});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.