asp.net - Javascript Date Validation -


How to validate the date of a particular format using javascript? I have a date picker in which the display format is "dddd MMMM dd, yyyy" (thus displaying: "Wednesday February 03, 2010".) I have to validate this format using Javascript. Please help me to apply it.

If you absolutely In that format, you can use regular expression:

  var re = new RegExp ('^ (Monday | Tuesday | Wednesday | Friday | Saturday | Sunday) \\ s * (January | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Nov | Dec |) * (\\ d \\ d), \\ s * (\\ d {2,4}) $ ') ; Var date = 'Wednesday February 03, 2010'; If ((match = date.match (re)) = null) {// valid warning (match); }  

Or if you just need to know that this is a valid date, anytime in the format, just change it:

  var dateSec , DateObj, dateStr = 'Wednesday February 03, 2010'; DateSec = date.pras (dateStr); // Unix timestamp if (dateSec) // No nan date obz = new date (dateSec); // Date Object  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -