我得到這個錯誤,並且很難糾正它。我收到以下錯誤消息:callback.call不是函數callback.call不是函數
我已經在下面發佈了代碼片段以進行評論,但似乎錯誤是在調用validateCheckBox(o)時觸發的。我明白,錯誤是由一個函數超出上下文觸發的,但不完全確定如何解決。
function checkLength(o, n, min, max) {
console.log(arguments.length);
if (arguments.length < 4) {
// issue here with callback.call is not a function
if (validateCheckBox(o)){
validateCheckBox(o);
}
}else {
if (o.val().length > max || o.val().length < min) {
o.addClass("ui-state-error");
updateTips("Length of " + n + " must be between " +
min + " and " + max + ".");
return false;
} else {
return true;
}
}
}
function validateCheckBox(o) {
var css = $(".border").css({
"border-color": "",
"border-weight": "",
"border-style" : "",
"background-color": "",
"background-image": "",
"background-repeat":"",
"background-position":""
});
//console.log(css);
var invalidChkBox = {
"border-color":"#cd0a0a",
"border-weight":"1px",
"border-style":"solid",
"background-color": "#feflec",
"background-image": "url('lib/jquery-ui/css/images/ui-bg_glass_95_fef1ec_1x400.png')",
"background-repeat": "repeat-x",
"background-position": "50% 50%"
}
// throwing error callback is not defined
var isChecked = $("#verification").is(":checked");
if (isChecked == false || isChecked == undefined) {
$(".border" ).css(invalidChkBox);
o.addClass("ui-state-error");
$(".validateTips").text("You must agree that all information is accurate and true, by checking the box.");
}else{
// reported bug callback.call is not a function @error below
$(".validateTips").css('display', null).text("");
$(".border" ).css(css);
}
}
valid = valid && checkLength (verification, "Verification", 1);
在此先感謝。
提供了哪些參數給checkLength調用? – Mahout
(元素,字符串標籤,最小值,最大值)例如(「#first_name」,「名字」,3,30); – Michael