Here is an interesting little issue a reader ran into this week. Can you tell me why the following code throws an error?
<cftextarea name="comments" value="Congrats Obama!">
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:
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!" />