Question

Does anyone know of a solution to the following markup validation error? I'm not sure if this is an issue in ColdFusion or my own code, but the output of the following snippet does not validate correctly on W3C markup validation service:

Code

        <cfform class="SearchForm" id="SearchForm" action="">
            <fieldset>
                <cfinput type="text" class="TNameField" name="TName" autosuggest="cfc:MyCFC.MyFunction({cfautosuggestvalue})">
                <input type="button" class="TNameButton" value=" " />
            </fieldset>
        </cfform>

HTML Output

<form id="SearchForm" action="" method="post" class="SearchForm" onsubmit="return _CF_checkCFForm_1(this)">

The validation error is associated with the "name" attribute that ColdFusion automatically assigns to . The error message is the following:

there is no attribute "name"

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

I am assuming the AJAX requires the "name" attribute to function correctly. How do I resolve this validation error? Do I have to change my document type?

Was it helpful?

Solution

You do not have to have a name attribute on a form for AJAX to work properly (including any ColdFusion generated AJAX). Here is the relevant information from the name attribute of the cfform element:

In HTML format, if you omit this attribute and specify an id attribute, ColdFusion does not include a name attribute in the HTML sent to the browser; this behavior lets you use the cfform tag to create XHTML-compliant forms. If you omit the name attribute and the id attribute, ColdFusion generates a name of the form CFForm_n where n is a number that is assigned serially to the forms on a page.

Short answer: keep an id, remove the name attribue, and your page will validate. Don't forget that id must be unique across all elements in the page.

OTHER TIPS

I think it means the form tag name:

<cfform class="SearchForm" id="SearchForm" action="" name="SearchForm">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top