I just need to validate a texbox with the year yyyy with a datepicker dd-mm-yyyy. is there any way to do this using javascript? Thanks
This is how I would do it using 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
}
}
});
});
I hope I understood your question correctly, if not you should give me additional information..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.