SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    "Input Type" Error

    Hi,

    I added a search form to my site however the validator keeps creating an error based on "input" typle at the start of the 2 inputs. The problem is I thought input areas were labelled.

    Can anyone advise please what I should be using instead of input?

    Code:
    <form action="/products/searchresults" method="post">
    <input type="text" name="keywords" size="20" class="homepagesearch" />
    <input type="image"  value="Submit" src="/images/search.png" alt="Search" name="image" />
    </form>

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    What are you trying to validate it as?
    Your example validates perfectly as as XHTML 1.0 Transitional.

  3. #3
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi yes it is XHTML 1.0

    I just have it inside a standard DIV. The form works fine, it just creates an HTML error.

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Putting it inside a div makes no difference, it still validates.
    See here (if you scroll down the page, you can see the source).

  5. #5
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    731
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I am using XHTML 1 Strict. But it should still work. Is their anything else it could be down to?

  6. #6
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    The FORM element really should have a FIELDSET and LEGEND or at the bare minimum a block-level element. Remember INPUT are inline elements. The FIELDSET is usually supposed to come directly after the start FORM tag.

  7. #7
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,941
    Mentioned
    215 Post(s)
    Tagged
    12 Thread(s)
    Indeed, it doesn't validate as XHTML strict.
    The two lines containing the <input> elements throw the following error:
    Code:
    Document type does not allow element "input" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag"
    What this means is that you can't have the input element as a direct child of the form. They must be contained within one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del".
    As xhtmlcoder says you should probably put them in <fieldset> and <legend> tags.

    http://reference.sitepoint.com/html/fieldset
    http://reference.sitepoint.com/html/legend

  8. #8
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,203
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    It's also a good idea to include a label, even if you hide it for sighted users.


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
  •