开发者

Date comparison in Jquery

开发者 https://www.devze.com 2023-01-20 02:51 出处:网络
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 yea

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

精彩评论

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

关注公众号