Need Javascript for mm/dd/yyyy format

I

iHavAQuestion

I need to dispaly 'mm/dd/yyyy' on a text box(aspx page) by default.
When the user enters the date(only numerics) in the text box it should take
the date in that order.
eg.. if the user enters 01012008 on that text box, it should display
01/01/2008, adding '/' by itself.
if the user enters 12312008 on that text box, it should display
12/31/2008, adding '/' by itself.
I am having tuff time,Can anyone, please provide the code for this solution.
 
M

Mark Rae [MVP]

I am having tuff time,Can anyone, please provide the code for this
solution.

There's nothing built in to JavaScript for this, so you'll need to roll your
own. There are hundreds of examples on the web - GIYF - e.g.
http://blog.stevenlevithan.com/archives/date-time-format

However, a *much* better solution is to provide a date picker so that you
never need to worry about users entering invalid dates - what does 03092008
mean to you...?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top