Date comparison in Jquery
I want to compare the selected date and current date. Iam using jquery date picker. While using the following code only the date field comparison is takes place... How can i compare with month and year also... Advance thanks..
$(document).ready(function() {
开发者_如何学Python var objDate = new Date();
var selectedDate = document.getElementById("<%=txtRqstDate.ClientID %>").value;
var currentDate = $.datepicker.formatDate('dd/mm/yy', new Date());
if (Date.parse(selectedDate) > Date.parse(currentDate )) {
alert("Invalid date range!\n Please choose a date that is not later than today!")
return false;
}
else {
return true;
}
Pls use this.I thing it will solve ur problem
function ChDate(){
var objDate = new Date();
var selectedDate = document.getElementById("<%=txtRqstDate.ClientID %>").value;
if (selectedDate > objDate ) {
//do
}
else
{
//do
}
}
Pls chk the following link to get more functions http://www.w3schools.com/jsref/jsref_obj_date.asp It is possible to take split an do checking by using string.split(separator, limit)
精彩评论