Recent Topics

Strict validation - Search Form

Started by on Jul 12, 2006 – Contents updated: Jul 12, 2006

Jul 12, 2006 12:46    

I'm not sure about my fix for this ...
The Search form generated


which the validator spat out as invalid.
I poked around in blogs\inc\misc\_form.funcs.php
and edited the following..


if( !empty($name) ) echo ' name="'.$name.'"';



if( !empty($name) ) echo ' id="'.$name.'"';

Allows Strict XHTML validation and the Search Form seems to work...

Right.. Wrong ????

Related code block


* Builds a form header and puts GET params of $action into hidden form inputs
* @deprecated Deprecated by (@link Form::begin_form())
function form_formstart( $action, $class = '', $name = '', $method = 'get', $id = '' )
  if( $method == 'get' )
    $action = explode( '?', $action );
    if( isset($action[1]) )
    { // we have GET params in $action
      $getparams = preg_split( '/&|&/i', $action[1], -1, PREG_SPLIT_NO_EMPTY );
    $action = $action[0];
  echo '<form action="'.$action.'" method="'.$method.'"';
  if( !empty($name) ) echo ' id="'.$name.'"';
  if( !empty($id) ) echo ' id="'.$id.'"';
  if( !empty($class) ) echo ' class="'.$class.'"';
  echo '>';

Jul 16, 2006 18:53

You would have then two "id" attributes maybe..

What validator error do you mean? Perhaps that "name" should be lowercase?

Jul 17, 2006 01:35

Well, If you have a XHTML Strict doc type and run the W3C validator it won't validate.
I just ran a Strict Validation on and got


# Error  Line 556, column 13: there is no attribute "name" .
    <form name="SearchForm" method="get" class="search" action="http://b2evolution
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.

Jul 17, 2006 04:05

I see.. I've not recognized that we're talking about FORM here, but I've thought some INPUT element.

Hmm.. I cannot think of a reason why a form should have a name anyway?!

I'll comment out/ignore the "name" param in CVS HEAD.

Thanks for mentioning it.

Jul 26, 2006 04:13

Another one that causes a similar problem is the "more" anchor.


<p class="bMore"><a id="more340" name="more340"></a>- -</p>

W3C Validator (XHTML v1.1) wrote:

There is no attribute "name"

I've been changing it for a few versions now. I don't remember if it's an XHTML v1.0 strict problem or not, but in any case ... the "name" attribute is being deprecated in favor of "id".

Changing /inc/MODEL/items/_item.class.php (line 932) from


$output .= '<a id="more'.$this->ID.'" name="more'.$this->ID.'"></a>'.$more_anchor;
/* to */
$output .= '<a id="more'.$this->ID.'"></a>'.$more_anchor;

resolves the validation problem, with no loss in functionality. (And with "more" ... no worries of more than one. ;)

Jul 26, 2006 19:15

ok. I've just committed it to CVS HEAD. There were some more occurences of "<a name=.." which I've also fixed.

Form is loading...

Open Source CMS – This forum is powered by b2evolution CMS, a complete engine for your website.