I would much prefer the counter go into negative numbers than behave as it does currently, stopping any further data entry upon reaching its limit. I'd much rather the form throw an error on submit, "You need to limit the title field to 140 characters."
As a writer, it is much easier for me to edit down when I can see the whole text in front of me.
A previous version of Maxlength had the counter at "0" but still allowed further data entry. I'm sure that was deemed a big and fixed, though I preferred that to having the from stop me from further data entry.
Ideally this could be a configurable setting, but of course that's more work.
Anyway, great module, just thought I'd vote for the js tool going into negative numbers.
Shai
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | maxlength-exceed-limit.patch | 2.44 KB | kleinmp |
Comments
Comment #1
dawehnerOk this would be definitive a feature, then the validation on form submit should handle the length.
Comment #2
haleagar commentedI agree, that's what I'm looking for. Also it's the way to go with cut and paste text.
Comment #3
haleagar commentedas I expected it's an easy fix if you need it right away.
Just comment out the following lines (10-13) in maxlength.js
Comment #4
kleinmp commentedI set this up to change colors of the text and show an error when the maxlength is exceeded. It also allows the maxlength to be exceeded in case someone pastes in data so that none of it is lost.
Comment #5
dawehnerThe color schould be configurable.
This should be trasltable
You should write against the latest cvs version.
Powered by Dreditor.
Comment #6
Shai commented@kleinmp,
Thank you SO much. This is exactly what I wanted.
I applied the patch in #4 against Maxlength 2.0 beta 1 and it works as you described.
However, there is one (not so important) part that is broken:
If the user ignores the red text and ignores that the counter going has gone into negative territory and clicks "Save" anyway, Drupal throws a validation error giving feedback that the offending data in the maxlength affected field is too long. The screen redraws with all of the data preserved. But the js is now absolutely dead. The counter shows, in black, the value you had set for the number of characters. It will not count down or do anything.
Personally, I don't think this is such a big deal... it's about providing convenience... and this user has flagrantly ignored the UI which has given great feedback. So okay, the user now doesn't have use of the widget anymore.
I'm such a super-novice at JS that I didn't check out your code. If the problem I reported is easy to fix, that would be great. If not... I would still advocate for committing the patch to the module, or incorporating it as a setting choice. The module would be a much more sophisticated implementation of a countdown widget.
Shai Gluskin
Comment #7
dawehner.
Comment #8
kleinmp commentedWhen a form fails validation, the javascript added through form alters seems to fail. I think that it may be because the form is now pulled from the form cache and it doesn't actually go through the entire form_alter process. There is a similar issue with css.
This is probably why the maxlength js is not working after failing validation.
In the past, I've had to fix this by adding javascript in with my theme instead of on form_alter, but this issue goes beyond this module, and I'd be curious if anybody has a good solution for it.
Comment #9
infojunkie+1
Comment #10
cedeweyThe Drupal 6 version of Maxlength is no longer supported so I'm marking this Closed (works as designed).
I also encourage you, if you haven't already, to upgrade your site to Drupal 8/9. We are actively maintaining that version and you would enjoy all of the other features of the latest version of Drupal.