C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Javascript »

Date compare


Posted Date: 20 Sep 2009    Resource Type: Code Snippets    Category: Javascript
Author: kamleshMember Level: Bronze    
Rating: 1 out of 5Points: 3



Hi
This script solve your date campare problem with javascript function that apply with custom validation controls........so use easily ...You can make easily date formate in dd/mm/yyyy.


function CompareDates()
{
var str1 = document.getElementById("ctl00_ContentPlaceHolder1_txtto").value;
var str2 = document.getElementById("ctl00_ContentPlaceHolder1_txtfrom").value;
var dt1 = parseInt(str1.substring(0,2),10);
var mon1 = parseInt(str1.substring(3,5),10);
var yr1 = parseInt(str1.substring(6,10),10);
var dt2 = parseInt(str2.substring(0,2),10);
var mon2 = parseInt(str2.substring(3,5),10);
var yr2 = parseInt(str2.substring(6,10),10);
var date1 = new Date(yr1, mon1, dt1);
var date2 = new Date(yr2, mon2, dt2);
if(date2 <= date1)
{
//alert("You are Correct");
return false;
}
else
{
alert("Required Date Must Be Greater Than System Date");
document.form1.Submit();
}
}


thanks & best regards,
kamlesh sancheti



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Date compare script  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Hide JavaScript Error
Previous Resource: Scheduling and Canceling the Functions
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use