[英]How to compare texbox with datepicker
我只需要使用datepicker dd-mm-yyyy验证带有yyyy年份的texbox。 有没有办法用javascript做到这一点? 谢谢
这是我如何使用JQuery做到这一点:
$(function() {
$("#your_datepicker").datepicker({
onSelect: function(dateText, inst) {
var startDate = new Date(dateText);
var selectedYear = startDate.getFullYear(); // selected year
var textbox = document.getElementById("txtBox").value //you might need to cut the string depending on how the user should enter the year in the textbox
if(textbox === selectedYear{
// Do what you need to
}
}
});
});
我希望我能正确理解你的问题,如果没有,你应该给我更多信息..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.