[英]Date comparison is not working in jQuery listener
警報顯示每個更改事件,但是if
條件不起作用。 如何解決?
這是我的代碼。
$("input").change(function() {
var date = document.getElementById('<%= txtRegisteredDate.ClientID%>').value;
var todaydates = new Date().format('dd/MM/yyyy');
if (date > todaydates) {
alert('date is greater than today date');
}
})
在比較之前,嘗試將日期變量轉換為對象。
例如:
var date = document.getElementById('<%= txtRegisteredDate.ClientID%>').value;
var todaydates = new Date();
if((new Date(date) > todaydates))
{
alert('date is greater than today date');
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.