473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Text Entry For Dates With Slashes?

I have a textbox in a form, and I need to allow users to enter dates
in US Format (MM/DD/YYYY). But they do not want to type any slashes,
just 8 numbers, and have the slashes added for them.

What is the best way to do that?

Thanks.
Jul 20 '05 #1
4 2171

"bdwise" <br************@hotmail.com> wrote in message
news:59**************************@posting.google.c om...
I have a textbox in a form, and I need to allow users to enter dates
in US Format (MM/DD/YYYY). But they do not want to type any slashes,
just 8 numbers, and have the slashes added for them.
This is fairly trivial to do server side. Where it would have to be done
anyways!

Pick your server side language and ask there.

Jeff

What is the best way to do that?

Thanks.

Jul 20 '05 #2
In article <59**************************@posting.google.com >,
br************@hotmail.com enlightened us with...
I have a textbox in a form, and I need to allow users to enter dates
in US Format (MM/DD/YYYY). But they do not want to type any slashes,
just 8 numbers, and have the slashes added for them.

What is the best way to do that?

Thanks.


Well, you can modify my code that takes a mm/dd/yy and makes it into
mm/dd/yyyy if you like.

You'll still have to do it server-side, too, unless you are certain ALL
your users use script and that they can't submit the form with script
turned off. This assumes an intranet environment.

Let me know if you want to see my code. It's NN6+/IE5+ (and DOM object
compatible) only for my intranet app.

--
--
~kaeli~
A midget fortune teller who escapes from prison is a small
medium at large.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #3
JRS: In article <59**************************@posting.google.com >, seen
in news:comp.lang.javascript, bdwise <br************@hotmail.com> posted
at Mon, 2 Feb 2004 14:48:02 :-
I have a textbox in a form, and I need to allow users to enter dates
in US Format (MM/DD/YYYY). But they do not want to type any slashes,
just 8 numbers, and have the slashes added for them.


Evidently you did not read the FAQ with sufficient care. The following
will do the job for UK dates.

S = S.replace(/(\d\d)(\d\d)(\d{4})/, "$1/$2/$3")

The following will convert un-punctuated UK dates to ISO-8601

S = S.replace(/(\d\d)(\d\d)(\d{4})/, "$3-$2-$1")

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #4
Thanks, Dr. Stockton. There is nothing in the FAQ about having
slashes added for the users as they type. I have started to play with
the onKeyDown event and such, and have not had any luck so far. I
need to trap the 3rd and 5th keystroke if unless it's a backspace or
left arrow and add the slash, etc. It appears that the FAQ deals with
formatting dates with slashes after a user has typed a value.

I apologize, my original post was not clear enough.

Dr John Stockton <sp**@merlyn.demon.co.uk> wrote in message news:<VD**************@merlyn.demon.co.uk>...
JRS: In article <59**************************@posting.google.com >, seen
in news:comp.lang.javascript, bdwise <br************@hotmail.com> posted
at Mon, 2 Feb 2004 14:48:02 :-
I have a textbox in a form, and I need to allow users to enter dates
in US Format (MM/DD/YYYY). But they do not want to type any slashes,
just 8 numbers, and have the slashes added for them.


Evidently you did not read the FAQ with sufficient care. The following
will do the job for UK dates.

S = S.replace(/(\d\d)(\d\d)(\d{4})/, "$1/$2/$3")

The following will convert un-punctuated UK dates to ISO-8601

S = S.replace(/(\d\d)(\d\d)(\d{4})/, "$3-$2-$1")

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Craig Thomson | last post by:
I was wondering what people do with text provided by the user in a form. Some cleaning needs to be done at some stage if you are going to be putting it in a database or displaying it etc. But when...
13
by: lawrence | last post by:
A user writes this sentence: "It was the New Urbanist's nightmare of sprawl run amok." They input that and my PHP script hits it with addslashes() and then the sentence gets put in the database....
9
by: Thomas W | last post by:
I'm developing a web-application where the user sometimes has to enter dates in plain text, allthough a format may be provided to give clues. On the server side this piece of text has to be parsed...
3
by: Randy | last post by:
I want to set up a table where I can enter dates that will prevent data entry of Dates in the Main table. I have done this in Approach by linking two tables and setting up a validation formula...
4
by: Russ | last post by:
Is it possible to create a input mask on a text box? If a user enters a date like this 060103 I would like to see it automatically converted to 06/01/03. In Access if you set a input mask to...
8
by: libsfan01 | last post by:
how can i use regular expressions to ensure a mysql format date entry in a text field? thanks marc
5
by: Stan | last post by:
I am working on a database in ACCESS 2003. Six of the fields provide for entry of service dates 1 to 6 progressively recording when the client was serviced. The data type is Date/Time. I need to...
4
by: Mehbs | last post by:
Hi guys: I am very new to C# and would really appreciate if someone please help. This is my first project and I am learning c#. I have to create a form where user enters start date and end...
4
by: Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post by:
I have created a report. This report needs to display records between two dates entered by the user. I put two text boxes on the report so I can enter the start and end date - I set them to use an...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.