Closed (fixed)
Project:
Content Construction Kit (CCK)
Version:
4.7.x-1.x-dev
Component:
text.module
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
20 Sep 2006 at 22:34 UTC
Updated:
30 Nov 2006 at 20:01 UTC
Jump to comment: Most recent file
Comments
Comment #1
eliza411 commentedI agree that this should be built-in, but until it is . . . here are some steps that look like they'll work. We did it a bit differently, putting maxlength into the attributes, but that's a non-standard value and your page won't validate. When I get a little more time, I'll probably change to the way they're doing it here.
http://drupal.org/node/80122
Comment #2
karens commentedHere's a simple patch to get the text module to do the validation for you.
Comment #3
Caleb G2 commentedWow, thanks Karen!
Comment #4
yched commentedJust as a comment : it should probably be noted that this "max length" includes the html tags.
Meaning if your textarea uses TinyMCE (for instance), this limit is only "unpredictably" related to what the user actually "sees".
Maybe there could be an additional (I know...) checkbox to specify if the max length is intended with or without tags (and then use
strip_tagsPHP function).Comment #5
karens commentedI guess I was assuming that this would be used by people who are not using html, since 'length' in an html document is really meaningless (do you count all the empty spaces that don't display in the finished html or somehow try to count only spaces that actually get displayed in the finished document, etc. etc.) Stripping the tags would only be a start to trying to figure out the length of the displayed text. If I was using html I would leave maxlenth to 0 and not validate it.
Comment #6
yched commentedYes, I didn't think about whitespaces.
I think the relevant target here is what gets displayed in the final html output. Multiple spaces/tabs/linebreaks could be tackled with a rather simple preg_replace.
What are the other "etc, etc" you have in mind ?
Comment #7
karens commentedNot really sure, I haven't thought it through. Carriage returns, indents, blockquotes, etc. What is the length of indented text like blockquotes or ul or dl items, for instance? Do you count the bullet as a space? What else is there in html where the display is different than the source code? As I said, I haven't really thought it through other than to think it might be a lot more complicated than it would appear.
Comment #8
RobRoy commentedI'd say just include all characters/tags in the max length. It would be too difficult to determine what the char count of a WYSIWG field would be. Maybe throw something in the help text about that.
Comment #9
karens commentedCommitted this change (simple test for length of the field). No validation is done if length is set to zero, so you can use that if you have html code in the field since it appears that may be too complex to address. At any rate, if a value is set the module should certainly validate it, so this seems like a bug that needs to be fixed.
Comment #10
dkruglyak commentedCould we add a feature to also validate for min length?
This is also a common requirement - to ensure that the input meets minimum content size standards.
Comment #11
yched commentedhttp://drupal.org/node/97983 has been added for "min length" validation.
Comment #12
(not verified) commented