Name of Form Element begin with number

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Viet

    Name of Form Element begin with number

    I have problem in retrieve a value of a form element that have name
    begin with a number. For example, for this HTML code
    <input type="text" name="0000ABC12 345CD6789" id="0000ABC1234 5CD6789">
    I got Javascript error at document.form.0 000ABC12345CD67 89.value

    Thanks.
  • kaeli

    #2
    Re: Name of Form Element begin with number

    In article <9138b68.040115 0955.6bde7db@po sting.google.co m>,
    vietla@juno.com enlightened us with...[color=blue]
    > I have problem in retrieve a value of a form element that have name
    > begin with a number. For example, for this HTML code
    > <input type="text" name="0000ABC12 345CD6789" id="0000ABC1234 5CD6789">
    > I got Javascript error at document.form.0 000ABC12345CD67 89.value
    >
    > Thanks.
    >[/color]

    Don't use the shortcut syntax if your elements begin with numbers or
    special characters. It's not very cross-browser, anyway.

    And I sure hope you didn't name your form "form"...

    Sub your formname here.
    document.forms["formname"].elements["0000ABC12345CD 6789"].value

    --
    --
    ~kaeli~
    A man needs a mistress... just to break the monogamy.



    Comment

    • Laurent Bugnion, GalaSoft

      #3
      Re: Name of Form Element begin with number

      Hi,

      Viet wrote:
      [color=blue]
      > I have problem in retrieve a value of a form element that have name
      > begin with a number. For example, for this HTML code
      > <input type="text" name="0000ABC12 345CD6789" id="0000ABC1234 5CD6789">
      > I got Javascript error at document.form.0 000ABC12345CD67 89.value
      >
      > Thanks.[/color]

      This is not legal HTML.

      From the HTML 4.01 specs:
      <quote>
      # ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
      followed by any number of letters, digits ([0-9]), hyphens ("-"),
      underscores ("_"), colons (":"), and periods (".").
      </quote>

      See the specs at
      <URL: http://www.w3.org/TR/html401/types.html#type-cdata>

      Laurent
      --
      Laurent Bugnion, GalaSoft
      Software engineering: http://www.galasoft-LB.ch
      Private/Malaysia: http://mypage.bluewin.ch/lbugnion
      Support children in Calcutta: http://www.calcutta-espoir.ch

      Comment

      Working...