Jquery日期选择器,如果是今天的日期,则执行一个对话框
我想设置此 jquery 日期选择器,以便在所选日期是今天的日期时引发警报/对话框。我正在使用 smarty,这就是你看到的日期函数。但是,当我输入今天的日期时,脚本仍然不会返回代表今天的对话框。这是脚本:
$("#sanctionDateStart").datepicker({
altField: "#sanctionDateStart_hidden",
altFormat: "yy-mm-dd",
minDate: new Date()
}).datepicker("setDate", "{$data.sanctionDateStart}").change(function () {
$('#sanctionDateEnd').datepicker('option', 'minDate',
$(this).datepicker('getDate'));
if ($(this).datepicker('getDate') == '{date("m/d/Y", $smarty.now)}'){
alert ('Todays Date');
}
else {
alert ('Not Todays Date');
}
});
I am wanting to set this jquery date picker to throw an alert / dialog if the date selected is todays date. I am using smarty, thats the date function you see. However when I input todays date, the script will still not return the dialog that represents today. Here is the script:
$("#sanctionDateStart").datepicker({
altField: "#sanctionDateStart_hidden",
altFormat: "yy-mm-dd",
minDate: new Date()
}).datepicker("setDate", "{$data.sanctionDateStart}").change(function () {
$('#sanctionDateEnd').datepicker('option', 'minDate',
$(this).datepicker('getDate'));
if ($(this).datepicker('getDate') == '{date("m/d/Y", $smarty.now)}'){
alert ('Todays Date');
}
else {
alert ('Not Todays Date');
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用日期选择器 onSelect 而不是 .change
Use Datepicker onSelect instead of .change
日期选择器返回一个
Date
对象,该对象不能等于字符串。您需要将 Smarty 中的字符串转换为 JSDate
。请参阅日期
文档了解如何这样做。The date picker returns a
Date
object, which can't be equal to a string. You need to convert the string from Smarty into a JSDate
. See theDate
documentation to see how to do that.