Re: Valid form element names? How to use ID instead of name? Processing form data

Discussion in 'HTML' started by Robert, Mar 6, 2004.

  1. Robert

    Robert Guest

    In article <pxj2c.694705$JQ1.149439@pd7tw1no>,
    "Grahammer" <postmaster@127.0.0.1> wrote:

    > Sorry for the newbie questions...
    >
    > Is there a link somewhere that shows what defines a valid form object
    > (element) name or ID?
    >



    While HTML allows more characters in the name, you may run into problems
    with certain characters. It depends on how you plan on accessing the
    variable in JavaScript.

    To put the names directly in JavaScript statements

    <input type="hidden" name="required_reg_type_1" value="">

    document.forms[0].required_reg_type_1.value

    I'd go with this:

    Letters and numbers plus underscore.

    "First, you cannot use any reserved keywords as a variable name."

    "Variable names have a couple of other important restrictions. Avoid
    all punctuation symbols except for the underscore character. Also, the
    first character of a variable name cannot be a numberal." from
    JavaScript Bible 4th edition by Danny Goodman.


    Or as pointed out ealier in this thread. You can use the quoted way of
    access in html name. This could be the preferred style. I do not know.

    I guess to address the interaction between how JavaScript and HTML
    define names, you can be assured by using the quoted style or make sure
    your names do not conflict with JavaScript. I tend to make all my
    variable names contain at least two words, such as requiredRegType1 or
    required_reg_type_1.


    Robert
     
    Robert, Mar 6, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jukka K. Korpela
    Replies:
    3
    Views:
    778
    Michael Winter
    Mar 6, 2004
  2. Michael Winter
    Replies:
    4
    Views:
    594
    Lasse Reichstein Nielsen
    Mar 6, 2004
  3. DU
    Replies:
    0
    Views:
    4,043
  4. Replies:
    2
    Views:
    505
  5. Replies:
    6
    Views:
    179
Loading...

Share This Page