473,497 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

spaces (and worse) in names ?

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"...> ?
Feb 1 '06 #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/

Feb 1 '06 #2
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
Feb 1 '06 #3
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>

Feb 1 '06 #4

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

Similar topics

1
2471
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...
3
2635
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...
2
11061
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...
2
1948
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...
22
4933
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...
135
7338
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...
40
2684
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...
3
12397
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...
12
5037
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...
0
6991
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...
0
7160
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,...
1
6878
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...
0
5456
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,...
0
4583
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...
0
3088
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1405
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 ...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.