Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 323
  • Last Modified:

Javascript function to check the valid date

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
PNKJ
Asked:
PNKJ
  • 2
1 Solution
 
Peter KwanAnalyst ProgrammerCommented:
0
 
PNKJAuthor Commented:
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
 
Peter KwanAnalyst ProgrammerCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now