Results 1 to 4 of 4

Thread: do form elements have to be in a form to be valid?

  1. #1
    Join Date
    Jun 2008
    Posts
    16
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default do form elements have to be in a form to be valid?

    For instance, can I have

    <li><a href=#>Value of My Car</a><input type="text"></li>

    But not within <form> tags?

    The idea is that the <input> field would be filled in with data coming from the server, calculated from other places.

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    I don't personally know, but just write the code, then upload it to the HTML validator here: http://validator.w3.org/

    And it should say whether it's valid or not.

    Edit: Pretty sure it's valid, just made a mock-up version but the validator didn't pick it up as an error.

    Also make sure you end the <input> tag with a / like this: <input type="text"/> or W3 will tell you you have errors, using doctype XHTML Transitional anyway.
    Last edited by Schmoopy; 12-03-2008 at 01:34 AM.

  3. #3
    Join Date
    Jun 2008
    Posts
    16
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default

    Thanks! Yeah I'll remember to close the tag too.

  4. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    The INPUT element defines a form control for the user to enter input. While INPUT is most useful within a FORM, HTML 4 allows INPUT in any block-level or inline element other than BUTTON. However, old browsers such as Netscape 4.x will not display any INPUT elements outside of a FORM.
    http://htmlhelp.com/reference/html40/forms/input.html

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •