Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Need Javascript for mm/dd/yyyy format

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
iHavAQuestion - 21 Mar 2008 17:23 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.