Forum Moderators: phranque

Message Too Old, No Replies

Validation Error? Please Advise

         

andmunn

4:03 am on Oct 31, 2004 (gmt 0)

10+ Year Member



I'm finally got down to validating all my pages of my site ( 100+), and it seems that , for the life of me, I cannot get rid of one error:

It reads:

Line 45, column 59: there is no attribute "NAME"

<form name="form" class="margin" action="">

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute.

Now, i've narrowed this down to my "header" area of my website, which includes the following code:

<form name="form" class="margin" action="">
<select name="site" size=1 onChange="javascript:formHandler()">
<option value="">Browse Our Network
<option value="http://www.surplusnetworks.com">Surplus Networks</option>
<option value="http://www.surplusnetworks.com/bb">Surplus Community</option>
</select>
</FORM>

The actually entry on my webpage, with regards to the Javascript programming is:

function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}

Any advise regarding this is appreciated - when this is done, everything will validate correctly! yay!

Thanks,
Andrew.

photon

2:15 pm on Oct 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're using an XHTML strict doctype, it's probably the onChange that's the issue. Change it to all lowercase, and the error should go away.

XHTML strict expects all tags and attributes to be in lowercase.

encyclo

2:25 pm on Oct 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Line 45, column 59: there is no attribute "NAME"
<form [b]name="form"[/b] class="margin" action="">

It's as it says: there is no attribute "name" defined in the DTD you have selected. Which doctype are you using?

You can replace

name="form"
with
id="form"
, but you may need to adjust your Javascript in consequence.

andmunn

2:45 pm on Oct 31, 2004 (gmt 0)

10+ Year Member



This is the "DOCTYPE" statement:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

It's not strict, i don't believe :)

Andrew.

vkaryl

4:02 pm on Oct 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope, that's definitely NOT strict!

I had this problem with a form on one of my pages a while back. I removed the "form name" section (wasn't at all necessary in my application), which made it happy.... I have other "name" selectors in the same form, but they aren't causing any problems.

If there's a reason for using "form name = form" that you can't go around, then you might try seeing if there's a newer version of the script you want to use, a different but similar script out there somewhere, or as encyclo says, use "id" instead of form and try to tweak the script so it works.

kaled

12:17 am on Nov 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can access forms as document.forms[n]
The first form on the page is given by n = 0
The name attribute is, therefore, redundant. However, I am surprised that it is rejected. Perhaps there is an error earlier in the page. Try validating an ultra-simple page that includes a named form.

Kaled.

encyclo

12:58 am on Nov 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

Ah-ha! HTML 4.0 messed up and left out the

name
attribute for the
form
tag. This was fixed in HTML 4.01 - and as the latest corrected version with all the bug fixes, that is the version you should be using. You just need to switch your doctype to this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0[b]1[/b] Transitional//EN">

Then your page will validate with the

name
attribute in place.

vkaryl

1:11 am on Nov 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Heh - encyclo, it's a good thing YOU are smarter than the average bear! Didn't see that one at all.... *sigh*

andmunn

1:14 am on Nov 1, 2004 (gmt 0)

10+ Year Member



Ah ha! that seems ot have done it :) I couldn't do a work around with teh "id=" function, but changing it to 4.01 does the trick.

Thanks again - finally :) all 100+ pages validate! Yay!

Andrew.