JQueryValidation plugin error: "Uncaught TypeError: Cannot call method 'call' of undefined"

StackOverflow https://stackoverflow.com/questions/22443067

  •  15-06-2023
  •  | 
  •  

Question

I'm having some problems with the excellent JQueryValidation plugin.

I have read some similar questions and the common thread with them seems to be that a plugin method isn't included - however, the remote and type methods are in the core of the plugin and don't need to be included.

Another odd detail is that the registerEmail field usually validates when the input blurs.

When you type into the registerEmail field, it validates fine, but the error sometimes shows and sometimes it doesn't.

When you click the Submit button, the error always shows.

Here is my relevant code:

HTML

<form id="registrationForm" action="dostep2.asp" method="get">

     <input type="text" id="registerName" name="registerName" placeholder="Enter your Name." />
     <input type="text" id="registerEmail" name="registerEmail" placeholder="Enter your Email Address." />

     <button type="submit" name="submitButton1" value="submitButton1" class="btn btn-default btn-lg proceed">
          </span>Proceed to <strong>Payment</strong> <span class="glyphicon glyphicon-circle-arrow-right">
     </button>

</form>

JavaScript

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

<script type="text/javascript">

        var validator = $("#registrationForm").validate({

            debug: true,

            rules: {

                registerName: {
                    required: true
                },

                registerEmail: {
                    required: true,
                    email:true,
                    remote: "http://beta.mysite.com/Testmail.asp",
                    type: "get"
                },

                registerPassword: {
                    required: true
                },

                registerPasswordConfirm: {
                    required: true,
                    equalTo: "#registerPassword"
                },

                registerSub: {
                    required: true,
                    type: "get",
                    remote: "http://beta.mysite.com/testsub.asp"
                }

            },

            messages : {

                registerName: "Please type in your name.",
                registerEmail: "Please type in your e-mail.",
                registerPassword: "Please type in your password.",
                registerPasswordConfirm: "Please confirm your password.",
                registerSub: "Please type the subdomain you want to use."

            }


        });

    </script>

Thanks in advance!

Was it helpful?

Solution

Quote OP:

" the remote and type methods are in the core of the plugin and don't need to be included."

Not quite. remote is a method but type is not...

registerEmail: {
    required: true,
    email:true,
    remote: "http://beta.mysite.com/Testmail.asp",
    type: "get" // <- this is not a method or rule
},

type is an option of remote and therefore goes inside of it...

registerEmail: {
    required: true,
    email: true,
    remote: {
        url: "http://beta.mysite.com/Testmail.asp",
        type: "get"  // <- this is an option of 'remote'
    }
},

See: http://jqueryvalidation.org/remote-method/

However, since type: "get" is already the default, you should be able to leave it out entirely...

registerEmail: {
    required: true,
    email: true,
    remote: "http://beta.mysite.com/Testmail.asp"
},
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top