[thelist] javascript and form fields with numeric ID/name

Simon Perry thelist at si-designs.co.uk
Thu Dec 2 13:23:10 CST 2004


Joel D Canfield wrote:

>Does javascript choke on a field id/name which begins with a numeric
>character? (like 010010CompanyName)
>
>If so, is there an workaround? Really wanted to be able to sort/group
>using the field id on the back end
>
>Finally, what on earth would you google up to find the answer to this
>seemingly basic question? I've spent half an hour in a fruitless attempt
>to answer this for myself.
>
>  
>
This is a DOM problem not really javascript at all. A document id may 
not start with a number, hyphen or underscore [0] so your above example 
the field / id name is invalid and causing your woes.

I'm not really sure what sorting or manipulation you are trying to 
achieve but you could add a letter before your string and strip it out 
in your sort function. But that sounds like a bit of a kludge... hard to 
know without more detail.

As for google sometimes it is a lot easier when you know the answer ;-)

Simon


[0] http://www.w3.org/TR/REC-CSS2/syndata.html#q4
http://www.w3.org/Style/css2-updates/REC-CSS2-19980512-errata.html#x3


More information about the thelist mailing list