我想验证第一个字段并在其他字段中显示内容。检查日期并显示说明。
除非我引入 var Date
,否则我的脚本正在运行$(document).ready(function () {
$('#holidayDate').datepicker();
var availableTags = ["New years Day", "Martin Luther King Day", "Groundhog Day", "Valentine's Day", "Washington's Birthday",
"Easter", "Earth Day", "National Arbor Day", "Mother's Day", "Memorial Day", "Flag Day", "Father's Day", "Independence Day",
"Labor Day", "Columbus Day", "Halloween", "Veterans Day", "Thanksgiving Day", "Pearl Harbor Remembrance Day", "Christmas Day"
];
$("#tags").autocomplete({
source: availableTags
});
var Date = [Date().january().third().monday(), Date().february().third().monday()];
$('#holidayDate').change(function () {
var dateString = $(this).val().substring(0, 5);
switch (dateString) {
case '01/01':
res = availableTags[0];
break;
case Date[0]:
res = availableTags[1];
break;
case '02/02':
res = availableTags[2];
break;
case '02/14':
res = availableTags[3];
break;
case Date[1]:
res = availableTags[4];
break;
case '04/22':
res = availableTags[6];
break;
case '06/14':
res = availableTags[10];
break;
case '07/04':
res = availableTags[12];
break;
case '10/31':
res = availableTags[15];
break;
case '11/11':
res = availableTags[16];
break;
case '12/07':
res = availableTags[18];
break;
case '12/25':
res = availableTags[19];
break;
}
$('#tags').val(res);
});
});
答案 0 :(得分:2)
您正在使用保留字(日期)。
将其设置为
var myDate = [Date().january().third().monday(),Date().february().third().monday()];
答案 1 :(得分:0)
声明名为Date的变量时,不能使用内置Date对象。将变量重命名为其他内容。