Wednesday, May 22, 2013

Date Difference Function in java script

/*---------------------Find DateDifference in java script-------------------*/

function Datediffrence(datefrom, dateto) {
    var startDate = Date.parse(datefrom);
    var endDate = Date.parse(dateto);
    var timeDiff = endDate - startDate;
    daysDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
    return daysDiff;
}


Example : How to find date diffenece not greater than 30 days




      //No.of Days Difference
        function FindDateDifference(sender, args) {

            var daysDiff = Datediffrence(document.getElementById('<%=txtDateFrom.ClientID %>').value, document.getElementById('<%=txtDateTo.ClientID %>').value)
            if (daysDiff > 30) {
                args.IsValid = false;
            }
            else {
                args.IsValid = true;
            }
        }



If you are searching life partner. your searching end with kpmarriage.com. now kpmarriage.com offer free matrimonial website which offer free message, free chat, free view contact information. so register here : kpmarriage.com- Free matrimonial website