开发者

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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜