[英]jQuery UI Datepicker getDate returns today's date on invalid date
When using jQuery UI's date-picker, if you call getDate
while the text in the text box is not a valid date, getDate
returns today's date. 使用jQuery UI的日期选择器时,如果在文本框中的文本不是有效日期时调用
getDate
,则getDate
返回今天的日期。
How can I distinguish between today's date and an invalid date when retrieving the date? 检索日期时如何区分今天的日期和无效的日期?
Looks like this is normal behaviour for the widget. 看起来这是小部件的正常行为。 Here's a function that includes support for invalid date checking:
这是包含对无效日期检查的支持的功能:
/* Gets the current value
* @return Date The result or null if no date is present
* @throws If the entered value is invalid
*/
function getDate(datePicker) {
datePicker = $(datePicker);
var format = datePicker.datepicker("option", "dateFormat"),
text = datePicker.val(),
settings = datePicker.datepicker("option", "settings");
return $.datepicker.parseDate(format, text, settings);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.