Solved

Javascript function to check the valid date

Posted on 2006-10-29
3
300 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

733 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