Solved

Javascript function to check the valid date

Posted on 2006-10-29
3
267 Views
Last Modified: 2010-04-16
Hi ,
I am looking for a isvalid date function that woud check only date is entered into the date field and not other characters. Also the format of date is mm/dd/yyyy
0
Comment
Question by:PNKJ
  • 2
3 Comments
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 17828768
0
 

Author Comment

by:PNKJ
ID: 17829034
I checked this it is doing to many things. All I need is valid date is entered and not unnecessary characters like a bc
0
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 500 total points
ID: 17829091
How about this?

http://www.javascriptkit.com/script/script2/validatedate.shtml

If you just want not to allow unnecessary characters then you can just do the following:

var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
if (!validformat.test(input.value)) {
    alert("Invalid Date Format. Please correct and submit again.")
    return false;
}
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This is an explanation of a simple data model to help parse a JSON feed
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now