SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form won't validate

    A form that validated in XHTML 1.0 won't validate in HTML 4.01 strict. This is the code I wrote:
    HTML Code:
    <form name="login" method="post" action="<?php echo ($_SERVER['PHP_SELF']);?>" onsubmit="return validateForm(this)">
     
    <fieldset>
    	<legend><strong>Your Sign in Information</strong></legend>
     
    <p><label for="lgn" class="short">Sign In ID:</label>
    <input type="text" name="lgn" id="lgn" class="txt" onchange="isNotEmpty(this)" ></p>
     
    <p> <label for="pwd" class="short">Password:</label>
    	<input type="password" name="pwd" id="pwd" class="txt" onchange="isNotEmpty(this)" ></p>
     
    	<p><input type="submit" name="lgnSubmit" id="lgnSubmit" value="Log in" ></p>
    </fieldset>
    	</form>
    This is the code the validator sees:
    HTML Code:
    110: <form name="login" method="post" action="/user_home.php" onsubmit="return validateForm(this)"><input type="hidden" name="PHPSESSID" value="fcba589539b8f6d313f3c8fb79455c02" />
    111: 
    112:	<fieldset><input type="hidden" name="PHPSESSID" value="fcba589539b8f6d313f3c8fb79455c02" />
    113:	 <legend><strong>Your Sign in Information</strong></legend>
    114: 	
    115: 	<p><label for="lgn" class="short">Sign In ID:</label>
    116: 	<input type="text" name="lgn" id="lgn" class="txt" onchange="isNotEmpty(this)" ></p>
    117: 	 
    118: 	<p> <label for="pwd" class="short">Password:</label>
    119:	 <input type="password" name="pwd" id="pwd" class="txt" onchange="isNotEmpty(this)" ></p>
    120: 	
    121:	 <p><input type="submit" name="lgnSubmit" id="lgnSubmit" value="Log in" ></p>
    122: 	</fieldset>
    123:	 </form>
    The W3C error messages are:
    Below are the results of attempting to parse this document with an SGML parser.
    1. Line 110, column 177: document type does not allow element "INPUT" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag

      ...e="eec9aa2c7223d2f245d79b8d2c86bd6b" /></p>

      The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

      One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").


    2. Line 110, column 178: character data is not allowed here

      ...="eec9aa2c7223d2f245d79b8d2c86bd6b" /></p>

      You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>) or forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes).


    3. Line 110, column 182: end tag for element "P" which is not open

      ...c9aa2c7223d2f245d79b8d2c86bd6b" /></p>

      The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.

      If this error occured in a script section of your document, you should probably read this FAQ entry.


    4. Line 112, column 92: start tag for "LEGEND" omitted, but its declaration does not permit this

      ...e="eec9aa2c7223d2f245d79b8d2c86bd6b" />

    5. Line 113, column 11: document type does not allow element "LEGEND" here

      <legend><strong>Your Sign in Information</strong></legend>

      The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

      One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).


    6. Line 115, column 3: document type does not allow element "P" here; missing one of "OBJECT", "MAP", "BUTTON" start-tag

      <p><label for="lgn" class="short">Sign In ID/label>

    7. Line 118, column 3: document type does not allow element "P" here; missing one of "OBJECT", "MAP", "BUTTON" start-tag

      <p> <label for="pwd" class="short">Password/label>

    8. Line 121, column 6: document type does not allow element "P" here; missing one of "OBJECT", "MAP", "BUTTON" start-tag

      <p><input type="submit" name="lgnSubmit" id="lgnSubmit" value="Log in" ></p>

    9. Line 122, column 11: end tag for "LEGEND" omitted, but its declaration does not permit this

      </fieldset>

    10. Line 112, column 13: start tag was here

      <fieldset><input type="hidden" name="PHPSESSID" value="eec9aa2c7223d2f245d79b
    I tried adding paragraph tags and such, to no avail. The hidden fields are no doubt generated by the session. I could use some help sorting out what the parser wants me to change in the code so it will validate.

    After migrating a few of my pages and scripts, I'm beginning to wonder if it's worth it. Stuart Langridge in his new Sitepoint book DHTML Utopia: Modern Web Design seems to think so (Introduction, pgs. x-xii). Thoughts?
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  2. #2
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By the way, I just removed the presentation tags <strong></strong> and that removed one error. I also removed all <p></p> tags and that removed several errors, though now the form is all in one line.

    The code now is:
    HTML Code:
     <form name="login" method="post" action="<?php echo ($_SERVER['PHP_SELF']);?>" onsubmit="return validateForm(this)">
     
    <fieldset>
    	<legend>Your Sign in Information</legend>
     
    <label for="lgn" class="short">Sign In ID:</label>
    <input type="text" name="lgn" id="lgn" class="txt" onchange="isNotEmpty(this)" >
     
    <label for="pwd" class="short">Password:</label>
    	<input type="password" name="pwd" id="pwd" class="txt" onchange="isNotEmpty(this)" >
     
    	<input type="submit" name="lgnSubmit" id="lgnSubmit" value="Log in" >
    </fieldset>
    	</form>
    The parser sees:
    HTML Code:
     110: <form name="login" method="post" action="/user_home.php" onsubmit="return validateForm(this)"><input type="hidden" name="PHPSESSID" value="1f9bf792e5d59671ab207430a8b36dac" />
    111: 
    112:	<fieldset><input type="hidden" name="PHPSESSID" value="1f9bf792e5d59671ab207430a8b36dac" />
    113:	 <legend>Your Sign in Information</legend>
    114: 	
    115: 	<label for="lgn" class="short">Sign In ID:</label>
    116: 	<input type="text" name="lgn" id="lgn" class="txt" onchange="isNotEmpty(this)" >
    117: 	 
    118: 	<label for="pwd" class="short">Password:</label>
    119:	 <input type="password" name="pwd" id="pwd" class="txt" onchange="isNotEmpty(this)" >
    120: 	
    121:	 <input type="submit" name="lgnSubmit" id="lgnSubmit" value="Log in" >
    122: 	</fieldset>
    123:	 </form>
    The error messages are:
    1. Line 110, column 174: document type does not allow element "INPUT" here; missing one of "P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE", "DIV", "ADDRESS" start-tag

      ...e="1f9bf792e5d59671ab207430a8b36dac" />

      The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

      One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").


    2. Line 110, column 175: character data is not allowed here

      ...="1f9bf792e5d59671ab207430a8b36dac" />

      You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>) or forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes).


    3. Line 112, column 92: start tag for "LEGEND" omitted, but its declaration does not permit this

      ...e="1f9bf792e5d59671ab207430a8b36dac" />

    4. Line 113, column 11: document type does not allow element "LEGEND" here

      <legend>Your Sign in Information</legend>

      The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

      One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).


    5. Line 122, column 11: end tag for "LEGEND" omitted, but its declaration does not permit this

      </fieldset>

    6. Line 112, column 13: start tag was here

      <fieldset><input type="hidden" name="PHPSESSID" value="1f9bf792e5d59671ab2074
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  3. #3
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is one of the problems with PHP sessions. This is why I don't often use <fieldset>s. I've heard that there is an option in newer versions of PHP that can fix this.

    What those errors are saying is that <legend> has to be the first child element of <fieldset> and that empty elements like <input> can't have the closing slash in HTML 4.01 Strict.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, but the main problem is that the hidden PHPSESSID field is added immediately after the <form> tag. Since FORM can only contain block-level elements as immediate children with a strict DTD, you're out of luck.

    You either have to take a backwards step to Transitional, or stop using automatic PHP session IDs.
    Birnam wood is come to Dunsinane

  5. #5
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AutisticCuckoo, if you look at paulcj2's code again you might notice that the <input type="hidden" name="PHPSESSID"> is a direct child of <fieldset>, not <form>.

    Quote Originally Posted by paulcj2
    Code:
     110: <form name="login" method="post" action="/user_home.php" onsubmit="return validateForm(this)"><input type="hidden" name="PHPSESSID" value="1f9bf792e5d59671ab207430a8b36dac" />
    111: 
    112:	<fieldset><input type="hidden" name="PHPSESSID" value="1f9bf792e5d59671ab207430a8b36dac" />
    113:	 <legend>Your Sign in Information</legend>
    This may mean that paulcj2's server already has the new PHP option set. Too bad it's still broken.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  6. #6
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please say more about the new PHP option. I can ask my hosting company about it if I know how to describe it and to see if, indeed, it is broken.
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  7. #7
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kravvitz
    AutisticCuckoo, if you look at paulcj2's code again you might notice that the <input type="hidden" name="PHPSESSID"> is a direct child of <fieldset>, not <form>.
    Look on line 110, and scroll to the right if necessary...
    Birnam wood is come to Dunsinane

  8. #8
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see that at line 110. I'm trying to follow up with my hosting company. To do that I need the on the name of the "new PHP option" you are talking about and how it might make a difference.
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  9. #9
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  10. #10
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Kravvitz. I'll look into those links.
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  11. #11
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Paul,

    I had a similar problem getting my form to validate as strict. The link below might help you out, it did for me.

    http://www.allinthehead.com/retro/212/and-breathe-out

    Hope it helps,

    Andy


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
  •