Are spaces allowed in names ?
Eg <input name="my field" type="text" value="my data">
The html4 dtd seems to say this is cdata, which allows embedded single
spaces, but say agents may trim leading & trailing space, and should
replace any whitespace character(s) with a single space.
It then goes on to give further constraints "not expressed by the DTD",
restricting id & name to a letter, followed by alphanumerics, hyphen,
underscore, colon and/or period.
So are spaces permitted, or not, and more to the point how universally
do they work ?
(they work for me in fx1.5 and ie6/w2k)
they even work on the vms/osu webserver, which uppercases everything!
The reason I ask is that I have a database driven application with
generated field names, containing spaces, possibly some punctuation, and
maybe even accented characters eventually, and I'm wondering how to
handle it.
Talking of which - how should I handle multi-national input on a web
form (accented names etc) ? Is it <form accept-charset="ISO-8859-1"...> ? 3 2938
Chris Sharman wrote: The reason I ask is that I have a database driven application with generated field names, containing spaces, possibly some punctuation, and maybe even accented characters eventually, and I'm wondering how to handle it.
To be on the safe side, you can
use regular expressions to alter the data as it arrives. I'd
strip the leading and trailing spaces and punctuation, and
substitute underlines for internal spaces in the actual field names.
With another regular expression, you can sub spaces for
underlines for printable labels and the like.
Perl, PHP, Python, and Ruby all have easy access to regular
expressions. Friedel's "Mastering Regular Expressions" is
a good book to have in your library. It's like learning a small
extra language, but it's really necessary for a lot of website
tasks.
--
mbstevens http://www.mbstevens.com/
Chris Sharman wrote: Are spaces allowed in names ? Eg <input name="my field" type="text" value="my data">
Yes, spaces are allowed in those attribute values.
The html4 dtd seems to say this is cdata,
Right.
which allows embedded single spaces,
It allows any number of spaces; value="", value=" "
and value=" " are all OK.
but say agents may trim leading & trailing space, and should replace any whitespace character(s) with a single space.
That's an obscure point and hardly what the spec writers _meant_ in
general. Surely alt="" should be treated as distinct from alt=" ".
Surely value="foo" and value=" foo " in an <input> element should be
treated differently. I would be surprised if browsers behaved
differently. But this seldom matters in practice; we hardly need to rely
on preservation of leading or trailing spaces.
It then goes on to give further constraints "not expressed by the DTD", restricting id & name to a letter, followed by alphanumerics, hyphen, underscore, colon and/or period.
No, the id attribute is constrained by the DTD as being of type ID,
whereas the name attribute has different rules for different elements.
In <a name="...">, rules are quite different from <input name="...">.
The reason I ask is that I have a database driven application with generated field names, containing spaces, possibly some punctuation, and maybe even accented characters eventually, and I'm wondering how to handle it.
I wouldn't worry about spaces or punctuation. Non-ASCII characters are a
different matter, and you need to consider how they can be transmitted.
Talking of which - how should I handle multi-national input on a web form (accented names etc) ? Is it <form accept-charset="ISO-8859-1"...> ?
The accept-charset attribute is probably ignored by all browsers. What
matters in practice is the encoding of the _page_ containing the form.
As usual, I recommend Alan Flavell's "tutorialish notes" on this: http://ppewww.ph.gla.ac.uk/~flavell/...form-i18n.html
On Wed, 1 Feb 2006, Chris Sharman wrote: Talking of which - how should I handle multi-national input on a web form (accented names etc) ? Is it <form accept-charset="ISO-8859-1"...> ?
Don't use ISO-8859-1 for forms. Only Netscape 3 could take advantage.
(Sorry, Mr. Daniels.) Netscape 4 could take advantage of ISO-8859-5
for Russian, ISO-8859-7 for Greek, etc. But ISO-8859-1 is of no use.
ISO-8859-1 is dangerous for forms because you cannot prevent readers
of inserting characters outside Latin-1. Strange things may happen
in this case. Read http://ppewww.ph.gla.ac.uk/~flavell/...form-i18n.html
--
Netscape 3.04 does everything I need, and it's utterly reliable.
Why should I switch? Peter T. Daniels in <news:sci.lang> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ketulp_baroda |
last post by:
Hi
I am storing the attachments in files on the server.User can see all
the attachments & view any of them.
My application shows the attachment correctly for file which have no
spaces in their...
|
by: larry |
last post by:
Hi,
I am a newbie to Internet programming. I have some questions about
spacing in HTML control names and subsequently being able to access
these input elements in JavaScript If you don't have...
|
by: Michael Bulatovich |
last post by:
I have a simple db to keep track of work/time/projects etc. It has two
fields (column) named "start time" and "end time"
WITH THE SPACES. I'm trying to do some automation to a form associated with...
|
by: Nick J |
last post by:
Hi,
I have a field called 'Transaction ID' but I can not use it in VBA because I
get the error message 'COMPILE ERROR: expected: end of statement' . I am
sure this is because of the space?
If...
|
by: rtilley |
last post by:
# Spaces are present before and after the XXX
filename = ' XXX '
new_filename = filename.strip()
if new_filename != filename:
print filename
Macs allow these spaces in file and folder...
| |
by: Xah Lee |
last post by:
Tabs versus Spaces in Source Code
Xah Lee, 2006-05-13
In coding a computer program, there's often the choices of tabs or
spaces for code indentation. There is a large amount of confusion about...
|
by: raphfrk |
last post by:
I have a program which reads in 3 filenames from the command line
prog filename1 filename2 filename3
However, it doesn't work when one of the filenames has spaces in it
(due to a directory...
|
by: Luke - eat.lemons |
last post by:
Hi,
Could someone tell me the correct quotation to get around spaces in
paths for:
Server.MapPath("\\server\share\spaces in name.mdb")
I know its bad practice to use spaces but...
|
by: Wayne |
last post by:
I have been given the task of rewriting a database that seems as
though it has been written by someone with a very basic understanding
of Access. Many of the object names and field names in tables...
|
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...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |