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).
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.
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!
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.
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.
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>
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.
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.
An avid fan of business, education, technology and finance. I lead a lean, highly focussed and capable team of Java Back End developers and Front End developers through a maze of complex software wizardry to fulfill the web maintenance needs of a large chemical manufacturer. As per Myers-Briggs Personality Types, I am an ESTJ. I pride in a project completed on time and according to plan. My hobbies include all kinds of technology, anything that I can taste and anything that goes fast or flies in the air. I like to read business books and comics in my spare time.
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.
I doubt if that works with real XHTML. I guess this is more the solution for HTML 4.01 Strict.
Thanks for your “name” tip. I was able to update the following form to XHTML 1.0 strict.
Text Area HighLight
Abid Omar: FORM still cant have the “name” tag.
Thanks for the tip man!
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
The id instead of name in a form can be a tricky part, but this solves it nicely.
thanks a lot ) very useful tip!
3rd place in google by “xhtml strict form name” =)
respect from russia ^^
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.
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!
Thanks for the tips dude. Worked a treat.
Here’s how I used it.
There is a easier way.
document.forms[ 0 ].submit()
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.
Thanks!! works perfect! Xhtml 1.0 STRICT
Thanks! Exactly what I was looking for. document.forms[‘headerForm’].submit() makes SO much more sense than document.forms[2].submit().
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:
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>
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>
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.