Link to home
Start Free TrialLog in
Avatar of Mick Barry
Mick BarryFlag for Australia

asked on

Allowed characters for input element name

What characters are valid for <input> element names?
SOLUTION
Avatar of Esopo
Esopo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Diablo84
Diablo84

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.
Avatar of Mick Barry

ASKER

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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I've actually run into this problem switching it from _ (for different reasons) :)
So call it using objForm.elements['MQ^15234^1^']?
>>...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?
> 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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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 :)
Glad we could... kinda help  ;-)