Here is an interesting little issue a reader ran into this week. Can you tell me why the following code throws an error?
<cfform name="foo">
<cftextarea name="comments" value="Congrats Obama!">
</cftextarea>
</cfform>
The error that is thrown is:
Attribute validation error for the CFTEXTAREA tag.
The value of the VALUE attribute cannot be defined twice. ''
Seems rather odd, doesn't it? There is clearly only one value attribute above. But the reader forgot that normally, the value of a textarea is defined between the beginning and end tag, like so:
<cftextarea name="comments">
Congrats Obamas!
</cftextarea>
Because his code had a line break between the start and end tag, ColdFusion considered that white space to be a value, and threw an error. Personally I think ColdFusion could just do a quick trim() check if it has an value attribute, but the fix is easy enough. You can move the value between the tags as I have before. Or you can remove the line break:
<cftextarea name="comments" value="Congrats Obama!"></cftextarea>
And lastly, you can just use a shorthand notation for the closing tag:
<cftextarea name="comments" value="Congrats Obama!" />
Archived Comments
Oh! Oh! Mr. Kotter!
I thought it should be:
<cftextarea name="comments">Congrats Obama!</cftextarea>
Yeah, that's fine. I always trim() everything from the Form scope anyway. ;)
Thanks for this info, it solved one problem I have, but not a second, loosely related, one.
Does anyone have problems with form validation failing on cftextarea where fckeditor is enabled? I get the validation alert that for all the fckeditor fields upon submit (even though the fields contain valid data), but if I immediately submit again, the form submits. Any idea why I have to submit twice? Tia, Sarah
Thanks for this Raymond! Solved my issue today