2010-05-18 114 views
0

我一直在为这个jQuery验证插件而苦苦挣扎。 下面是代码:
jQuery验证错误

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

这里是错误:

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

我完全糊涂了......也许需要某种处理的?
我会很感激任何答案。

回答

7

我认为它只是一个错字:

minlenght: 6 

应该

minlength: 6 
+0

按照同样的思路,我得到这个错误以及试图验证一个“IPv4的”类型。原来我没有包含'additional-methods.js'扩展,它里面有更多验证器...... – 2013-02-06 17:42:47