的阵列最后日期我有此循环,其检查用户是否点击已经存在于保留的数组的数组的日期。我的问题是它不应该警告用户,如果点击日期是其中一个数组中的最后日期。我希望这是有道理的。返回false,如果选择了日期是在阵列
arrayAfBookninger.forEach(function(array) {
var lastDay = array[array.length - 1];
array.forEach(function(dato) {
if (startdato == moment(dato).format("YYYY-MM-DD") || slutdato == moment(dato).format("YYYY-MM-DD")) {
alertify.alert("Datoen er allerede booket. Vælg venligst en anden dato.");
$("#startdato").val("");
$("#slutdato").val("");
}
datoerMellemStartSlut.forEach(function(val) {
if (moment(val).format("YYYY-MM-DD") === moment(dato).format("YYYY-MM-DD")) {
alertify.alert("Der er bookede datoer mellem den valgte start- og slutdato. Vælg venligst en anden dato.");
$("#startdato").val("");
$("#slutdato").val("");
}
});
});
});
如果用户点击17.这里,不应该显示警报。
到目前为止,我已经尝试保存在一个变量每个数组的最后一天,但我不知道如何将其应用到循环。现在,阵列中的所有日期都将与用户选择的startdate和enddate(slutdato)进行比较。我也不想从数组中删除日期,因为我需要它们仍然以日历中的颜色显示。
临时解决方法:
if (dato == lastDay) {
return;
}
请把演示代码的帮助更好 –
我设法通过简单的返回了foreach循环拿出一个解决方案,但我想用不同的方法,如果能够处理它。我已将代码添加到帖子中。 – Leth
Aderfe ellinas eisai? Gia ton eniko tou data => dato! Theoulis! –