首页 > 解决方案 > 确定日期字段是 NaN 还是空

问题描述

我提供以下代码供审查:

//THIS VALIDATES THE DATE ENTERED
var cMsg = "The date you entered is invalid.\n\nPlease enter a date that does not pre-date the previous entry date.";
var nIcon = 0;
var nType = 0;
var cTitle = "DATE ERROR";
var str = event.target.name;
var res = str.charAt(str.length-1);
var d1 = Date.parse(this.getField("0." + (res-1)).value);
var d2 = Date.parse(event.value);
if(d1 != null) {
if (d1 > d2) {
    app.beep();
    app.alert(cMsg, nIcon, nType, cTitle);
event.value = "";
}
} else {
var cMsg = "This is an invalid entry\n\nThe previous date entry cannot be empty.\n\nPlease use the entry above first.";
    app.beep();
    app.alert(cMsg, nIcon, nType, cTitle);
}

规则:

也许不是不允许输入(严格执行),我们只是提醒用户并确认他们希望继续,即使违反了预期的规则......这可能会更好。

这对我来说很困难。可以的话请帮忙。

标签: javascriptdateacrobat

解决方案


推荐阅读