post-page

Validate forms XHTML 1.0 Strict

17
responses
by
 
on
August 16th, 2004
in
Code, XHTML 1.0, XHTML 1.1, XHTML Tips
heading
heading
heading
17
Responses

 

Comments

  1. Abid Omar (1 comments.) says:

    If you enclose your form in a div, you won’t get all those “name” errors, and you then need not enclose each input tag in a separate container (or hidden fieldset).

    For details see Forms in XHTML 1.1.

  2. Anne (3 comments.) says:

    I doubt if that works with real XHTML. I guess this is more the solution for HTML 4.01 Strict.

  3. Ken says:

    Thanks for your “name” tip. I was able to update the following form to XHTML 1.0 strict.

    Text Area HighLight

  4. x0o (1 comments.) says:

    Abid Omar: FORM still cant have the “name” tag.
    Thanks for the tip man!

  5. Jannick (1 comments.) says:

    This was just what I needed for my javascript to work, and also to be able to validate my site as xhtml 1.1 strict. Thank you :D

    The id instead of name in a form can be a tricky part, but this solves it nicely.

  6. phen0m (1 comments.) says:

    thanks a lot ) very useful tip!
    3rd place in google by “xhtml strict form name” =)
    respect from russia ^^

  7. Lee says:

    Actually, in XHTML Strict, if you simply nest your form inside of a div, your XHTML will still not validate. All form elements (labels, input tags, etc) must be contained in a block-level element like a fieldset or a paragraph tag in order to validate.

  8. Lee says:

    I found this technique of using an “id” attribute in the form tag to work beautifully in XHTML Strict. I modified this slightly since my form calls a JavaScript function. I gave my form an id of “FormA” and in my JavaScript, I used this statement to talk to the form: var form = document.forms[‘FormA’];
    Thanks for the tip!

  9. someone says:

    Thanks for the tips dude. Worked a treat.
    Here’s how I used it.

  10. Mark says:

    There is a easier way.
    document.forms[ 0 ].submit()

  11. Eric says:

    I still prefered using then using an ID, if there is no name, some extension in dreamweaver will not work, it will say please name your form first, stupid that it does validate correctly using xhtml strict, but hey the name inside a form still works anyway, forget the rule.

  12. Happy says:

    Thanks!! works perfect! Xhtml 1.0 STRICT

  13. gnujack (1 comments.) says:

    Thanks! Exactly what I was looking for. document.forms[‘headerForm’].submit() makes SO much more sense than document.forms[2].submit().

  14. Bill says:

    Concerning the XHTML validation of a form. Instead of having to use with the fields and incuring an unwanted line break or using and some css to turn the box lines off, use instead, as others said. Here is an example of code that works for me. Note, the is ONLY used around the fields, NOT the entire form. Doing it around the whole form will not result in a XHTML Strict 1.0 validation, but this code will.

    username:
    password:

    • Bill says:

      My apologies, I thought I could post in some html code here for an example. I guess I need to modify it a bit for this to work. {=
      {div>
      username: {input type=”text” name=”username” />{br />
      password: {input type=”password” name=”password” />{br />
      {input type=”submit” value=”LOGIN” /> {br />
      {/div>
      {/form>

  15. Bill says:

    I guess one more time to get this posted correctly…

    Concerning the XHTML validation of a form. Instead of having to use <p> around the <input> fields and incurring unwanted line breaks or using <fieldset> and some CSS to turn off the box lines; use <div> instead, as others here have said. Here is an example of code that works for me. Note, the <div> is ONLY used around the <input>fields, NOT the entire form. Doing it around the whole form will not result in a XHTML Strict 1.0 validation, but this code will.

    <form id=”login” action=”http://wa5pb.freeshell.org/taarc_login-4.php” method=”post”>
    <div>
    username: <input type=”text” name=”username” /><br />
    password: <input type=”password” name=”password” /><br />
    <input type=”submit” value=”LOGIN” /> <br />
    </div>
    </form>

  16. Webstandard-Blog (1 comments.) says:

    Instead of using p or div, use a definition list (dl) to structure the content. Definition-Term (dt) for label content like, name, street, etc. and defnition description (dd) for the form-elements.



Obviously Powered by WordPress. © 2003-2013

page counter
css.php