Javascript日历跳过日期

时间:2013-04-05 14:43:35

标签: javascript internet-explorer internet-explorer-10

除了IE10之外,所有其他浏览器似乎都能正常运行,当选择一个月/年时,它会随机跳过一个月。

每次更改日期时都会引发错误,但是此错误似乎并不总是会导致问题

Unable to get property 'length' of undefined or null reference

正在使用的代码片段:

var vals;

if (typeof(targetedControl.Validators) != "undefined") {
    vals = targetedControl.Validators;
}
else {
    if (targetedControl.tagName.toLowerCase() == "label") {
        targetedControl = document.getElementById(targetedControl.htmlFor);
        vals = targetedControl.Validators;
    }
}

var i;

for (i = 0; i < vals.length; i++) {
    ValidatorValidate(vals[i], null, event);
}

1 个答案:

答案 0 :(得分:-1)

似乎vals为null /可能找不到targetedControl ...这应该让你知道:

if(!targetedControl || !vals)
{
    alert('Control Not Found!');
}
else
{
    for (i = 0; i < vals.length; i++) {
        ValidatorValidate(vals[i], null, event);
    }
}