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.
Mark Rae [MVP] - 21 Mar 2008 17:54 GMT
> 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...?

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Cowboy (Gregory A. Beamer) - 21 Mar 2008 18:03 GMT
Something like:
http://www.dotnetspider.com/kb/Article3037.aspx
If you are doing AJAX, there is a masked edit control:
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx

Signature
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss
or just read it:
http://gregorybeamer.spaces.live.com/
*************************************************
| Think outside the box!
*************************************************
>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
[quoted text clipped - 6 lines]
> I am having tuff time,Can anyone, please provide the code for this
> solution.