473,799 Members | 2,936 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

date format in forms?

hi everyone,

in my form i have to take some date information in dd-mm-yy format.
but i don't want user to use tabs while typing. for example s/he
should simply type 280104 but 28/01/04 must appear.

what can i do for that?
should i use three input tags? but then, how can i make the cursor
jump to the next field when typing in current field is done?
or if i use one input tag, how can i keep '/' signs in the field fixed
when user types the date?
Jul 20 '05 #1
25 19862
koray wrote:
hi everyone,

in my form i have to take some date information in dd-mm-yy format.
You should at least use a four digit year, to make it less ambiguous,
but I recommend you use the international standard (ISO 8601) which is
the format YYYY-MM-DD. There are also other variations, but that seems
the most appropriate for your needs.
but i don't want user to use tabs while typing. for example s/he
should simply type 280104 but 28/01/04 must appear.
Then just use one text field, and write a description of the format you
would like it to be in, in the fields label. But then the server side
processing and validation becomes slightly harder.

On the server, you can use a regex to parse the string, so if you
were expecting the date in dd-mm-yy, but you also want to allow the user
to enter ddmmyy or dd/mm/yy, then use a regex like this. (I don't
recommend using a / as the delimter because it's not used in the 8601
standard for that purpose, but it is commonly used by many people)

/([0-9]{2})[-\/]?([0-9]{2})[-\/]?([0-9]{2})/

When executed on the string, that will return an array, each cell
with 2 characters, which you can then convert to numbers. Then it's
just a matter of checking that each field is within range. Also, if
your interested, and would like to use the ISO 8601 format, then use
this regex.

/([0-9]{4})[-\/]?([0-9]{2})[-\/]?([0-9]{2})/
this allows
YYYY-MM-DD
YYYY/MM/DD
YYYYMMDD
(as well as incorrect versions like YYYY/MM-DD, but that doesn't really
matter, as long as it supports the correct versions)
what can i do for that?
should i use three input tags? but then, how can i make the cursor
jump to the next field when typing in current field is done?
If you want to use three input fields, then you could use javascript
to detect when they have written 2 digits, but I be careful of this. If
done incorrectly, it may make it difficult to the user to make
corrections because of the cursor unexpectidly jumping to the next field.
or if i use one input tag, how can i keep '/' signs in the field fixed
when user types the date?


Don't worry about it, just write a server side script that can handle it
however they enter it, but if your really worried about them entering it
absolutely correctly, then just modify the regexs above and return an
error message to them if they got it wrong.

--
Lachlan Hunt
http://www.lachy.id.au/
la**********@la chy.id.au.updat e.virus.scanners

Remove .update.virus.s canners to email me,
NO SPAM and NO VIRUSES!!!
Jul 20 '05 #2
Lachlan Hunt <la**********@l achy.id.au.upda te.virus.scanne rs> wrote:
If you want to use three input fields, then you could use
javascript
to detect when they have written 2 digits, but I be careful of this.
If done incorrectly, it may make it difficult to the user to make
corrections because of the cursor unexpectidly jumping to the next
field.


And even when made the best possible way, it confuses people.

As Nielsen writes:

"Splitting what users see as a single piece of information into multiple
fields means that users must waste time moving the cursor around. A
typical example is when forms ask users for their first and last names as
two items, rather than simply letting users enter their full name in a
single field, which is much faster to type. Another example is
[a collection of three fields for a telephone number]."

http://www.useit.com/alertbox/20031222.html point 9
(Too bad Nielsen doesn't put id attributes into his heading
elements, to allow referring to them with URI references.)

Even if we managed to save some of (most) users' time by using JavaScript
to automagically move to the next field, users easily get confused. They
are not used to "automoving ", and it's more difficult to recognize
something as a single entity when it has been split into several fields.

In principle, the server-side script should accept any format that can be
unambiguosly recognized. I would say that this means that no format with
a two-digit denotation should be accepted. Even though 01-02-03 is has a
single interpretation according to ISO 8601, we should not expect people
to know that meaning - actually most people mean something different.
Here we must accept the minor incovenience to users, I'd say, of forcing
them to type a year in four digits. But on the Web I think we need to go
farther and be rather restrictive about it, since 2/3/2001 isn't
absolutely clear either - it's probably meant to be interpreted the
American way, but it _could_ some day be meant to be read as
day/month/year. So this seems to boil down to accepting basically just
2001-02-03.

That's external to HTML of course. But the HTML implication is that a
single text input field is normally the best way to let the user enter a
date. I would use size="10" maxlength="10" as a hint, with an explanation
that says that date(s) be entered as year-month-day, with the year in
four digits.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #3
On Thu, 15 Jul 2004, Jukka K. Korpela wrote:
And even when made the best possible way, it confuses people.

As Nielsen writes:

"Splitting what users see as a single piece of information into multiple
fields means that users must waste time moving the cursor around. A
typical example is when forms ask users for their first and last names as
two items, rather than simply letting users enter their full name in a
single field, which is much faster to type. [ ... ] "


What's the "last name" of Jukka Korpela?
What's the "last name" of Mao Zedong?

I think it is a good idea to have two different fields and let the user
clarify what's his family name and what's his given name(s).

--
Top-posting.
What's the most irritating thing on Usenet?

Jul 20 '05 #4
Andreas Prilop wrote:
On Thu, 15 Jul 2004, Jukka K. Korpela wrote:
As Nielsen writes:

"[...] A typical example is when forms ask users for their first
and last names as two items, rather than simply letting users
enter their full name in a single field, which is much faster to
type. [ ... ] "


What's the "last name" of Jukka Korpela?
What's the "last name" of Mao Zedong?

I think it is a good idea to have two different fields and let the
user clarify what's his family name and what's his given name(s).


Strange conclusion. If it's unclear how the user's name should be
represented, shouldn't there be a single name field? Let the user type
it in as they see fit. If the family name should be first, they'll
type it that way. If it should be last, so it will appear in posted data.

I think addresses would be much easier that way, too. Where does the
postal code go? After the city (and state), like in the US, or before
it, like in France? How many digits are there? In the end, splitting
the address up into 5 or 6 fields (address1, address2, city,
state/province, postal code, country) is harder for the user, and
harder for the server-side programmer. It's probably better to put a
textarea in the form, and let people type in the address just like
they were typing a mailing label. I think most people can be counted
on to know how their address should look.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #5
Brian <us*****@juliet remblay.com.inv alid> writes:
Andreas Prilop wrote:
On Thu, 15 Jul 2004, Jukka K. Korpela wrote:
As Nielsen writes:
"[...] A typical example is when forms ask users for their first
and last names as two items, rather than simply letting users
enter their full name in a single field, which is much faster to
type. [ ... ] " What's the "last name" of Jukka Korpela?
What's the "last name" of Mao Zedong?
I think it is a good idea to have two different fields and let the
user clarify what's his family name and what's his given name(s).


Strange conclusion. If it's unclear how the user's name should be
represented, shouldn't there be a single name field? Let the user type
it in as they see fit. If the family name should be first, they'll
type it that way. If it should be last, so it will appear in posted data.


Also, there's no requirement to have both a given and family name. I
know of at least one person with only a single name.
I think addresses would be much easier that way, too. Where does the
postal code go? After the city (and state), like in the US, or before
it, like in France? How many digits are there? In the end, splitting
the address up into 5 or 6 fields (address1, address2, city,
state/province, postal code, country) is harder for the user, and
harder for the server-side programmer. It's probably better to put a
textarea in the form, and let people type in the address just like
they were typing a mailing label. I think most people can be counted
on to know how their address should look.


Agreed.

The exception, IMO, to Neilsen's advice, is for date/time fields,
where making sure users enter dates in the unambiguous numeric format
yyyy-mm-dd is, I think, unfriendlier than having three <select>s for
day, month and year.

Though where the year might be outside a small-ish range, obviously
that needs to be a text input, and then do all three become text
inputs for consistency?

Anyway, I think in some circumstances at least multiple inputs is a
better way to do date/time.

--
Chris
Jul 20 '05 #6
On 15 Jul 2004 15:27:25 +0100, Chris Morris <c.********@dur ham.ac.uk>
wrote:
Also, there's no requirement to have both a given and family name. I
know of at least one person with only a single name.


A name field is filled in by the user with their name in their preferred
form, so one field is fine.

Dates, though, have other uses. You might want to order things
chronologically , or see if more responses came in in September than July,
or in 2003 than 2004. Three fields is acceptable here. And I find most
sites use select boxes to choose a date, a spelled-out month, and a year.
Not that this makes it the best way, but clearly users are going to be
familiar with this way of doing it.
Jul 20 '05 #7

"Brian" <us*****@juliet remblay.com.inv alid> wrote in message
news:10******** *****@corp.supe rnews.com...
Andreas Prilop wrote:
On Thu, 15 Jul 2004, Jukka K. Korpela wrote:
As Nielsen writes:

"[...] A typical example is when forms ask users for their first
and last names as two items, rather than simply letting users
enter their full name in a single field, which is much faster to
type. [ ... ] "
What's the "last name" of Jukka Korpela?
What's the "last name" of Mao Zedong?

I think it is a good idea to have two different fields and let the
user clarify what's his family name and what's his given name(s).


Strange conclusion. If it's unclear how the user's name should be
represented, shouldn't there be a single name field? Let the user type
it in as they see fit. If the family name should be first, they'll
type it that way. If it should be last, so it will appear in posted data.


Forms don't split up entry of people's names just for fun. The essential
need behind split entry of the user's name is to be able to sort
alphabetically on family name. Reproducing each person's name in the order
particular to the person's culture is secondary and usually non-critical.

I think addresses would be much easier that way, too. Where does the
postal code go? After the city (and state), like in the US, or before
it, like in France? How many digits are there? In the end, splitting
the address up into 5 or 6 fields (address1, address2, city,
state/province, postal code, country) is harder for the user, and
harder for the server-side programmer. It's probably better to put a
textarea in the form, and let people type in the address just like
they were typing a mailing label. I think most people can be counted
on to know how their address should look.


The requirements of most applications require the address data to be split.
I don't know about other countries, but U.S. organizations, to get favorable
postage rates, need to be able to print mailing labels in order by ZIP
(postal) code. Organizations in general need to be able to filter
user/customer/member data by state (or province or whatever), city, and
postal code for a variety of purposes.

It's really hard to build a parser that knows all the rules necessary for
international commerce, but in spite of your suggestion to the contrary I
think most people can be counted on to know which part of their address is
the street, which is the city, which is the state, and so on. Have you ever
heard of anybody who gave up trying to order a book from Amazon because he
wasn't sure which part of his address was the city? The only time there's
confusion is when a site that is likely to receive international visitors
doesn't anticipate them with generic labels ("State, province, etc." versus
"State"; "ZIP Code" versus "Postal Code"), provides a drop-down list for
selecting the state without providing an alternate entry method for users
from other countries, and indiscriminatel y applies locale-specific
validation rules for postal codes, phone numbers, and so forth.

There *are* applications where the address is entered solely for
reproduction as is, and where there is no need to extract the components of
the address. I have built such applications, and in those cases I have made
"address" a single piece of data, with a multi-line entry field.

As for people's names, there are plenty of situations where they *don't*
need to be sorted, and in those cases, again, a single data item and a
single entry field suffice. This is especially true for names of people
other than the person on whose behalf a form is being completed. These
include data with labels like "Name of Spouse", "Name of Beneficiary", "Name
of Emergency Contact", and so forth.

Jul 20 '05 #8
koray wrote:
hi everyone,

in my form i have to take some date information in dd-mm-yy format.
but i don't want user to use tabs while typing. for example s/he
should simply type 280104 but 28/01/04 must appear.

what can i do for that?
should i use three input tags? but then, how can i make the cursor
jump to the next field when typing in current field is done?
or if i use one input tag, how can i keep '/' signs in the field fixed
when user types the date?


Here's a better idea for you. Use client side script to provide a
date widget that replaces a single text field (used for the fallback)
and let the user pick the date graphically. I've started working on
scripts to do this a few weeks ago during my spare time (though I
haven't updated it for a little while). It's still very much under
development, and much of it will change and actually become functional,
but it's a reasonable demonstration of how to at least generate a date
widget.

At the moment, it uses the built in javascript date object to parse a
date in the format: D MMMM YYYY (eg. 16 July 2004), but there's the
start of a script to parse an ISO 8601 date. It then generates the
calendar and highlits the current system date, and the date in the form
contol Feel free to experement with it. and if you like, send me any
changes.

The script, example form and some documentation are available for
viewing here:

http://www.lachy.id.au/script/examples/datetime/
http://www.lachy.id.au/xhtml/examples/forms/datetime/

The individual files should not yet be considered stable, and may be
modified, renamed or removed, but these directories will contain the
latest changes as I write and publish them (when I eventually find more
time to think about doing it).

--
Lachlan Hunt
http://www.lachy.id.au/
la**********@la chy.id.au.updat e.virus.scanners

Remove .update.virus.s canners to email me,
NO SPAM and NO VIRUSES!!!
Jul 20 '05 #9
Harlan Messinger wrote:
Brian wrote...
If it's unclear how the user's name should be represented,
shouldn't there be a single name field? Let the user type it in
as they see fit.
Forms don't split up entry of people's names just for fun. The
essential need behind split entry of the user's name is to be able
to sort alphabetically on family name.


I suppose. But a database can sort on a name, whether first + last or
last only.
I think addresses would be much easier that way, too. Where does
the postal code go? After the city (and state), like in the US,
or before it, like in France?


The requirements of most applications require the address data to
be split. I don't know about other countries, but U.S.
organizations, to get favorable postage rates, need to be able to
print mailing labels in order by ZIP (postal) code.


In that case, I might go for 2 fields: a mailing label <TEXTAREA>, and
a postal code for sorting. Of course, that raises the potential
problem that people might then not put the code in the <TEXTAREA>.
It's really hard to build a parser that knows all the rules
necessary for international commerce, but in spite of your
suggestion to the contrary I think most people can be counted on to
know which part of their address is the street, which is the city,
which is the state, and so on.
My point wasn't that users would get confused. My point was twofold:
(1) users can enter their address more easily in a textarea compared
to 6 input type=text elements. (2) it's not the users who will get
confused, it's the organization. It's hard for a commerce site to know
the proper address format for the US, France, China, Tanzania, etc.
Once they collect the city and postal code in separate inputs, how
will they know how to lay them out on their mailing labels?
from other countries, and indiscriminatel y applies locale-specific
validation rules for postal codes, phone numbers, and so forth.


Again, for telephone numbers, one should be "liberal in what you
accept": allow 0 or 1 at the beginning, allow space and formatting
characters ()-, and allow a variable amount of digits. This assumes
international visitors. For a site restricted to a country, a more
restrictive format may be appropriate.

--
Brian (remove ".invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #10

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

Similar topics

9
6374
by: insomniux | last post by:
Hi, I am having a problem with formatting the default value of a date field. It has been discussed earlier in many topics, but still I cannot solve the problem. What's happening: I have various forms which are based on an ODBC-linked tables. In one of the forms, I have a control which shows the date of a date field in my database (storage type=date). The default value for the control is set to '=Date()', the format property is set to...
20
35640
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the project the date format in vb.code ( not in Windows) and how can I find out which date format the PC Windows is using. Thanks for any response
7
6822
by: Richiep | last post by:
I am trying to get a UK format date of dd/mm/yyyy. Why does the following subroutine not return a valid date in a web form? The date returned is #12:00:00 AM# but the date I entered into the text box was 24/06/2006. The other solution I have tried is given by the following two lines that do not compile because a value of date type cannot be converted to datetime:
4
2739
by: saintor1 | last post by:
Access 97 - I want the date format YYYY-M M-DD to show everywhere. My problem is that I deal with French and English versions. And don't want to play with Windows Regional Settings. In the format property of a control, it is easy to enter YYYY-MM-DD But it won't work in French versions. In them, AAAA-MM-JJ will. Using format(MyDate,"yyyy-mm-dd") in the controlsource doesn't sem to
16
11918
by: Mik | last post by:
I apologise if this post seems a little basic, but I am a newbie and have NO access knowledge. I have downloaded the Accounts Ledger from the Microsoft Website. It allows the user to review a report of transactions between a Start & End date. The Tables and forms i believe are UK format "dd/mm/yyyy", However, when I click on "Review Reports" and enter the date as UK "dd/mm/yyyy", it returns nothing.
1
1884
by: Gilz | last post by:
Hi I am having trouble with the transfertext acexportdelim function. I have written several routines that export queries with date fields. I have put format statements in the download queries as so that the data is exported as dd/mm/yy. Every time i run this it exports the dates as dd/mm/yy nn:hh:ss i really don't understand why.
1
4044
by: Maciej07 | last post by:
Hello, We are using SQL server 2000 on W2k Server and MS Access 2000 ADP (like front-end). Now we try to change operating system for SQL Server 2000 from W2k to W2k3 and we found problem with date format - we receive error: "Cannot convert date type varchar to datetime". Datetime used in application are sent to SQL Server 2000 in format YYYY-MM-DD as varchar. (in Query Analyzer all view/query works fine but when application sends it...
10
5824
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a date format in the table design, such as: mm/dd/yyyy? What I've done for years is to store the date format in date fields, then on the forms, based on their region, I would set the date formats on form_load
3
421
by: Tony WONG | last post by:
The date format (control panel) of testing (VS2005) and production platform are yyyy/mm/dd. i run preview from testing (VS2005). The date format is yyyy/mm/dd however, when i put the code to production platform. The date format is dd/mm/yyyy what should i look to? Thanks a lot.
5
8253
by: Matsam | last post by:
Hello, I have an Access program with 4 forms. In the load event of the main form, I need to set the system date format to British. Can anyone please give the code for setting the system date format ? Thanks in advance Matsam
0
9540
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10250
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10026
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9068
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.