0
我正在使用jquery驗證插件來驗證jquery中的時間...但它總是顯示一個錯誤,這真的讓我拉我的頭髮。我如何在我的項目中使用jQuery驗證插件
Uncaught TypeError: Cannot call method 'addMethod' of undefined
$("input").blur(function() {
//var check =$(this).closest('tr').find('input');
$(this).each(function() {
$.validator.addMethod(this, function(value, element) {
return this.optional(element) || /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))?$/i.test(value);
}, "Please enter a valid time.");
$("#check").validate({
rules: {
input: "required time"
}
});
#檢查這裏是我的表格ID .. – Rozer
第一,請在沒有擴展方法的情況下嘗試驗證器。例如,只需要一個基本的「必需」。如果這樣做,嘗試在添加方法之前啓動驗證程序。 – TCHdvlp