Solved

Allowed characters for input element name

Posted on 2004-09-10
13
1,505 Views
Last Modified: 2013-11-19
What characters are valid for <input> element names?
0
Comment
Question by:objects
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +2
13 Comments
 
LVL 14

Assisted Solution

by:Esopo
Esopo earned 125 total points
ID: 12032144
Are there non-valid characters?
I guess it all depends on your character set, and what you plan to do with the input afterwards. For instance, it hapenned to me that a file not saved in UTF8 format containing "special chars" would get translated into  "weird chars" by my Unix server (some PHP in the middle). This was easily fixed by saving the file as UTF8 and declaring the same in the HTML header.

Are you having an specific problem we can help you with?
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 12032159
As far as im aware there is no standard which defines valid characters for naming inputs however if you are using it in conjunction with server side processing its advisable to follow the naming convention for variables (in the case of php atleast - which will be used upon handling the posted data) which is an underscore or a letter followed by any number/combination of letters, numbers and underscores.
0
 
LVL 92

Author Comment

by:objects
ID: 12032162
Yes, I'm starting to think its more a js problem.

I'm having problems using the following to access a form element:

objForm.MQ^15234^1^

where MQ^15234^1^ is the input element name
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Assisted Solution

by:Diablo84
Diablo84 earned 125 total points
ID: 12032172
I would imagine JS uses the same variable naming and object reference naming standards so its possible this is having an effect in the scripts functionality, is the use of the ^ characters essential? I suspect replacing them with underscores would fix the problem.
0
 
LVL 92

Author Comment

by:objects
ID: 12032191
I've actually run into this problem switching it from _ (for different reasons) :)
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12032292
So call it using objForm.elements['MQ^15234^1^']?
0
 
LVL 14

Expert Comment

by:Esopo
ID: 12032295
>>...switching it from _ ...<<
Did it not work with underscores? if so, maybe your problem is not in the variable naming but in something else related to your varaible. Maybe a duplicated name that is missleading you or something like that.

Can you post a link to your page?
0
 
LVL 92

Author Comment

by:objects
ID: 12032307
> So call it using objForm.elements['MQ^15234^1^']?

thats failing

> Did it not work with underscores?

it did work with _ but that was causing problems further down the track.

> Can you post a link to your page?

no its on our development site
0
 
LVL 36

Assisted Solution

by:Zyloch
Zyloch earned 125 total points
ID: 12032311
How odd. How does yours go? This is a quick thing I cooked up that illustrates my purpose:

<form name="myForm">
<input type="text" id="hi" value="Test!" name="MQ^15234^1^"><input type="button" value="Check it out!" onclick="alert(document.forms['myForm'].elements['MQ^15234^1^'].value);">
</form>
0
 
LVL 14

Expert Comment

by:Esopo
ID: 12032337
Just to make sure, this is all client side javascript, right? If there is a server request in the middle of the process it could be an invalid chars issue. What kind of exception is it producing? Also, are you using IE? maybe a browser issue?

Did Zyloch's code work on your system?
0
 
LVL 9

Accepted Solution

by:
cwolves earned 125 total points
ID: 12032490
alpha-numeric, _

can't start with a number.  That's the requirements for it to work with most DOM models, not sure about official naming schemes.
0
 
LVL 92

Author Comment

by:objects
ID: 12033332
Ended up going back to _ and doing a replace before posting to database.
Ran out of time to track down problem further so will split points between all.

Thanks for all your help :)
0
 
LVL 14

Expert Comment

by:Esopo
ID: 12033384
Glad we could... kinda help  ;-)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question