0

I have been struggling with this jQuery Validation Plugin. Here is the code:

<script type="text/javascript">
$(function() {

var validator =   $('#signup').validate({
    errorElement: 'span',
  rules: {
   username: {
        required: true,
        minlenght: 6
        //remote: "check-username.php"
        },
   password: {
    required: true,
    minlength: 5
   },
   confirm_password: {
    required: true,
    minlength: 5,
    equalTo: "#password"
   },
   email: {
    required: true,
    email: true
   },
   agree: "required"
  },
  messages: {
   username: {
    required: "Please enter a username",
    minlength: "Your username must consist of at least 6 characters"
    //remote: "Somenoe have already chosen nick like this."
   },
   password: {
    required: "Please provide a password",
    minlength: "Your password must be at least 5 characters long"
   },
   confirm_password: {
    required: "Please provide a password",
    minlength: "Your password must be at least 5 characters long",
    equalTo: "Please enter the same password as above"
   },
   email: "Please enter a valid email address",
   agree: "Please accept our policy"
  }

});

var root = $("#wizard").scrollable({size: 1, clickable: false});



// some variables that we need
var api = root.scrollable();

$("#data").click(function() {
  validator.form();
});

// validation logic is done inside the onBeforeSeek callback
api.onBeforeSeek(function(event, i) {

    if($("#signup").valid() == false){
      return false;
    }else{
      return true;
    }



$("#status li").removeClass("active").eq(i).addClass("active");


 });


 //if tab is pressed on the next button seek to next page
root.find("button.next").keydown(function(e) {
 if (e.keyCode == 9) {

  // seeks to next tab by executing our validation routine
  api.next();
  e.preventDefault();
 }
});
$('button.fin').click(function(){
     parent.$.fn.fancybox.close()
});


});
</script>

And here is the error:

$.validator.methods[method] is undefined
/js/jquery-validate/jquery.validate.min.js
Line 15

I am completely confused... Maybe some kind of handler is needed?
I would be grateful for any kind of answer.

1 Answer 1

7

I think it is simply a typo:

minlenght: 6

should be

minlength: 6
Sign up to request clarification or add additional context in comments.

1 Comment

Along the same lines, I was getting this error as well trying to validate an 'ipv4' type. Turns out I wasn't including the 'additional-methods.js' extension that has more validators in it...

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.