Check whether the date is less than the Current date using Javascript

No.of Views2155
Bookmarked0 times
Downloads 
Votes0
By  Troy   On  15 Feb 2010 23:02:08
Tag : ASP.NET , HTML and CSS
Check whether the date is less than the Current date using Javascript
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Introduction


Here we have to discuss the Whether the user entered date is less than the current date this has been checked by using javascript call the script on textChanged or button click event.

Technologies:

ASP.NET

Language:

Javascript





Implementation

try this simple javascript

{codecitation class="brush: javascript; gutter: true;" width="500px"}


function dateValidation()

{
var obj = document.getElementById("");

var day = obj.value.split("/")[0];
var month = obj.value.split("/")[1];

var year = obj.value.split("/")[2];
if ((day31) || (month12)&&(year.length != 4))

{
alert("Invalid Format");return false;

}

else

{
var dt = new Date(year, month-1, day);

var today = new Date();
if((dt.getDate() != day) || (dt.getMonth() != month-1) || (dt.getFullYear()!=year) || (dt>today))

{
alert("Invalid Date");return false;

}

}

}

{/codecitation}

Thank you

Venkat

 
Sign Up to vote for this article
 
About Author
 
Troy
Occupation-Not Provided
Company-Not Provided
Member Type-Junior
Location-Not Provided
Joined date-10 Jun 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top