Forum Moderators: not2easy

Message Too Old, No Replies

xhtml validation problem

xhtml 1.0 Transitional

         

LazyCarrot

4:34 pm on Sep 2, 2009 (gmt 0)

10+ Year Member



Ok - i'll own up to not really being a proficient coder - but in an attempt to impose some discipline on myself i decided to code in XHTML 0.1 Transitional.
Which was fine until i needed some coding that was beyond my meagre capabilities and i scrounged some and adapted it to my needs. It's a simple input form that just requires the user to enter a password which is checked against a list of hard-coded passwords and if it matches they get to go to the next page... Now, the coding works ok in Safari and IE8 but falls over completely in FireFox. Validation, of course, also throws up errors so Safari & IE8 are just being tolerant - Firefox is right - but a bit of a nuisance! :)
ok - so here's the code I'm using:

<form name=login>
<div style="text-align: right; width:210px; padding:5px;">
<div style="padding:3px; font: bold 13px arial;"> Log In:</div>
<div style="padding:3px; font: normal 13px arial;">Pass: <input type="password" name="username" size="15" maxlength="30" style="width: 100px"></div>
<div style="padding:3px;"> <input type=button value="Login" onClick="Login()" style="width: 65px;"></div>
</div>
</form>

There's javascript above this - but i think it's the form coding that's falling foul of validation.

I get a whole list of errors on validation - but i think most are knock-on effects of previous errors so the first one is: (pointing to form name=login)

an attribute value specification must be an attribute value literal unless SHORTTAG YES is specified

which I'm afraid means nothing to me.

If anyone can point out the error of my ways i'd much appreciate it - thanks!

LazyCarrot

5:26 pm on Sep 2, 2009 (gmt 0)

10+ Year Member



Hi - further to my post - i figured out the error message -it was just asking for quotes around the name - Firefox now accepts the form BUT it still fails XHTML Validation so from a purist viewpoint i'd still like to know if anyone can spot an obvious flaw....
Thanks for taking the time to read through this.... :)

mattur

5:41 pm on Sep 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



XHTML = all attributes must be quoted + all tags must be closed

You're not closing your <input>'s. They don't have end tags, so code them as self-closing instead:

Change <input ...> to <input ... />

i.e. space-slash at the end.

rocknbil

9:23 pm on Sep 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard LazyCarrot - one question:

....in an attempt to impose some discipline on myself i decided to code in XHTML 0.1 Transitional.

Why XHTML? Do you plan on doing any extending of the HTML set, plan on using any tools that require an XHTML doctype, is there any real reason you associate "discipline" with "XHTML?" Does your server output XHTML headers, or is the content-type still text/html?

I'm not picking on you - HONEST! - and I'm not knocking XHTML either, but you can be just as disciplined with an HTML 4.01 strict doctype, in which you can lose all the funny />'s. If you're coding HTML, you may as well describe your document as HTML.

But yes, unquoted attributes will still kick errors in 4.01, you just won't need all those closing tags on standalone elements.