soona Posted November 18, 2008 Share Posted November 18, 2008 Hi, "i want to display exact months and days displayed in two textboxes".This is my following, my code is not work . please check where i made mistake , if any easy way .please let me know. thanks in advance---------------function getDiff(){var date1 = document.getElementById( "gmdpEmpprojStartDate" ).value;var date2 = document.getElementById( "gmdpEmpProjEndDate" ).value;if (date1.indexOf("-") != -1) { date1 = date1.split("-"); } else if (date1.indexOf("/") != -1) { date1 = date1.split("/"); } else { return 0; }if (date2.indexOf("-") != -1) { date2 = date2.split("-"); } else if (date2.indexOf("/") != -1) { date2 = date2.split("/"); } else { return 0; }if (parseInt(date1[0], 10) >= 1000) {var sDate = new Date(date1[0]+"/"+date1[1]+"/"+date1[2]);} else if (parseInt(date1[2], 10) >= 1000) {var sDate = new Date(date1[2]+"/"+date1[0]+"/"+date1[1]);} else {return 0;}if (parseInt(date2[0], 10) >= 1000) {var eDate = new Date(date2[0]+"/"+date2[1]+"/"+date2[2]);} else if (parseInt(date2[2], 10) >= 1000) {var eDate = new Date(date2[2]+"/"+date2[0]+"/"+date2[1]);} else {return 0;}var one_day = 1000*60*60*24;var daysApart = Math.abs(Math.ceil((sDate.getTime()-eDate.getTime())/one_day));var one_month=(1000*60*60*24*31);var a=Math.abs(Math.ceil((sDate.getTime()-eDate.getTime())/one_month));document.getElementById( "txtEmpAvailabilityPeriod" ).value = a;var days=daysApart-2*30;document.getElementById( "TextBox1" ).value = days; ---------------With kind regards Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.