?
Solved

Javascript function to check the valid date

Posted on 2006-10-29
3
Medium Priority
?
311 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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 …
Introduction to Processes

770 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