/    Sign up×
Community /Pin to ProfileBookmark

Dual format date validation needed

Hi,

I’m looking for a script that will validate a date in at least two formats. Specifically, US (mm/dd/yyyy), and a custom format (yyyy/mm/dd). I’m already stripping out invalid characters, but I need to make sure that the date is in one of the proper formats, and that the day is correct.

I’ve tried taking existing scripts and combining them and changing around the formats, but I obviously don’t know enough about Javascript to make it work.

Any help would be very much appreciated.

Thanks!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisFeb 25.2004 — Why don't you just put in three text boxes; 1 for the year, 1 for the month and 1 for the day. Then at least you can move on to concentrate on the rest of the job.

BTW, what do you consider a "correct date"?

If you have split the date into pieces and removed the "/", then convert it to numbers and compare the numbers to what you consider correct.

You could also limit the user's choices by using drop downs for month and year. Then you just have to check the day to see if it exists for that month.
Copy linkTweet thisAlerts:
@tarkonauthorFeb 25.2004 — [i]Originally posted by gil davis [/i]

[B]Why don't you just put in three text boxes; 1 for the year, 1 for the month and 1 for the day. Then at least you can move on to concentrate on the rest of the job.



BTW, what do you consider a "correct date"?



If you have split the date into pieces and removed the "/", then convert it to numbers and compare the numbers to what you consider correct.



You could also limit the user's choices by using drop downs for month and year. Then you just have to check the day to see if it exists for that month. [/B]
[/QUOTE]



Unfortunately, I have to do one single text box - and for date validation it needs to check to make sure that the date isn't invalid (such as 05/99/04, 02/30/04, 14/14/04, etc.).
×

Success!

Help @tarkon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...