|
Posted by koray on July 15, 2004, 12:54 am
Please log in for more thread options
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?
|
|
Posted by Lachlan Hunt on July 15, 2004, 8:57 am
Please log in for more thread options
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])[-/]?([0-9])[-/]?([0-9])/
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])[-/]?([0-9])[-/]?([0-9])/
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/ lachlan.hunt@lachy.id.au.update.virus.scanners
Remove .update.virus.scanners to email me,
NO SPAM and NO VIRUSES!!!
|
|
Posted by Jukka K. Korpela on July 15, 2004, 9:35 am
Please log in for more thread options
> 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
|
|
Posted by Andreas Prilop on July 15, 2004, 3:08 pm
Please log in for more thread options 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?
|
|
Posted by Brian on July 15, 2004, 11:20 am
Please log in for more thread options 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/
|
| Similar Threads | Posted | | Ho to get (and format) today's date? | July 20, 2006, 1:43 pm |
| Forms - howto use return for submitting in Forms? | April 6, 2005, 4:08 pm |
| LAST_MODIFIED Date | June 23, 2007, 9:18 pm |
| DATE and TEXTAREA question | December 12, 2004, 6:10 pm |
| Is there a way to get web page creation date? | February 10, 2005, 12:30 pm |
| last modified date of a web page? | March 8, 2005, 1:15 pm |
| How to code "content-disposition" so that file modification date is maintained? | April 22, 2006, 6:30 pm |
| Can searching be customized -- To focus search-results & find up-to-date content? | August 1, 2006, 9:50 pm |
| Bad HTML tag format | August 1, 2006, 11:33 am |
| Entering . to format | January 5, 2008, 6:19 pm |
|