Validating forms in xhtml strict
Here is a sample to follow in order to make any form validate under xhtml strict rules:
<form action=”some bit of code here” method=”post” >
<fieldset>
<label>Enter your email address:</label>
<input type=”text” name=”email” />
<input type=”hidden” value=”some value” name=”url”/>
<input type=”hidden” value=”some value” name=”title”/>
<input type=”submit” value=”Subscribe” /><p>Powered by <a href=”a url”>Something</a></p>
</fieldset>
</form>
The key: put the fieldset tag around ALL the input statements.
[tags]xhtml, form[/tags]
Posted by Paul Flyer on Wednesday, June 28th, 2006 in Web Development




Darren Hudson Says:
July 13th, 2006 at 6:59 pm
your solution works for me to valid hidden input types, but a rounded rectangle appears around the form. do i need to add something to make this border invisible?
Paul Flyer Says:
July 13th, 2006 at 8:25 pm
Darren,
Very good question.
In you CSS file put the following:
fieldset {
border: 0;
}
This will remove the border around any fieldset tags in your code. Fieldset automatically creates a border around the objects it encloses. To learn more about fieldset check out this page.
sander-martijn Says:
July 10th, 2007 at 6:58 pm
As someone who’s done development for more than 13 yrs in all different languages, I have to say that’s the dumbest aspect of the new standards I’ve heard yet. Let’s just throw in another useless tag that does nothing for markup but defaults to something no one wants so everyone has to add in 3 lines of extra css…. wow. well thanks for straightening it out for me as the idea of input not validating inside form was almost as irritating to me as the solution.
Justin Says:
May 4th, 2009 at 11:53 am
that little css hack is invalid:
Value Error : border only 0 can be a length. You must put a unit after your number : 1
Steven Says:
May 14th, 2009 at 8:13 am
Great this has helped me!
and the css does validate.
Rob Says:
May 24th, 2009 at 6:39 pm
That last comment isn’t very clear, but if you’re using “border:0;” you’re setting the border off, which doesn’t require a unit of measurement. If you’re trying to set the border to “border:1;” then you have to include a unit as in “border:1px;”
XHTML Strict ve formlar - Zoque Says:
May 31st, 2009 at 2:13 pm
[...] 31.05.2009 | 22:13 | #3 http://www.recommendedwebtools.com/i…-xhtml-strict/ [...]
Mike Says:
June 25th, 2009 at 6:47 pm
Thank you, thank you, thank you. You’re solution to add around the form elements worked like charm.
Conpanna Says:
January 25th, 2010 at 2:13 am
Thank you! I was looking for it …
phillw Says:
February 2nd, 2010 at 9:18 am
Thanks a million !! I had a really complicated form with with drop-downs & calls to MySQL dbase – all works fine. Put 2 simple “Click to turn off / on” buttons in a seperate page and all hell broke loose – Yikes !!! I had to set the padding to zero, as well as border – just in case someone is still having problems.
Phill.