Solved

Javascript function to check the valid date

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

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