Profile picture for user admin
Daniel Sipos
10 May 2013

Maxlength is a cool module that allows you to set maximum character limits for your Drupal form text fields. Not only that users who fill in these forms can see the maximum number of characters they can write but they will also be prevented from writing more than they should.

It’s actually a very useful module for websites with a lot of content and contributors. News websites come to mind where certain text fields need to have a maximum character length in order to fit in designated areas around the site. It then reduces the efforts of editors who have to shorten news pieces.

Maxlength uses Javascript to dynamically show how many characters are left for users to write in the text box - kinda like with text messaging - which is very cool. But it’s also easy to set up for admins. After you install and enable it like a normal module, you’ll see that editing any textfield on a content type (apart from the default title field) you get some new options.

The most important one is setting the maximum number of characters a user is allowed to fill in the textfield. Then you can also set the message displayed to the user as the character count goes down, which is pretty cool. Additionally, you can set it so that html tags do not constitute characters that add up this count - which makes sense and allows for safe html truncating.

Give it a shot and see how it works. The issue queue is quite extensive for this module to check it out if you run into trouble.

Profile picture for user admin

Daniel Sipos

CEO @ Web Omelette

Danny founded WEBOMELETTE in 2012 as a passion project, mostly writing about Drupal problems he faced day to day, as well as about new technologies and things that he thought other developers would find useful. Now he now manages a team of developers and designers, delivering quality products that make businesses successful.

Contact us

Comments

dddave 13 May 2013 11:31

Neat find

That could be a really useful find. Thank you. I always cringe though if there is only a recent dev release (not the problem) and only a years old stable release (there's the problem). But I am definitely going to test it out.

side-note: I love the wordpress ads on this article.

Daniel Sipos 13 May 2013 13:34

In reply to by dddave (not verified)

Hey there,

Hey there,
Thanks for the comment.

Can I ask you what "only a years old stable release" means? One year as a stable release does not give enough confidence in the module's stability? I'm just curious about what you mean :)

Cheers!

dave 16 May 2013 16:30

Yes, but...

When I first found this module I was thinking it would be a great solution for the problem I was trying to solve. I have a text field (length of 255) but I only wanted a maximum length of 12 characters to be entered.

Q:Why not just make a test field with a length of 12 characters?
A: Because once there is data in the field the length can not be changed. So when I suddenly need to change the maximum length to 14 characters, I have to migrate all of the data to a new field and then to another field with the original field's name.

The Maxlength module doesn't allow you to actually set a maximum length. It get's it's max length from the field's max length. Shame it doesn't allow for a different length than the field's length.

JK 26 Dec 2015 03:50

Diminishing number of allowed characters

Will this module help me solve the issue of not being able to set a character limit in the future for a field that didn't used to have a limit? Trying to get future content to abide by the rule but leave old content untouched. Thanks!

Murz 27 Sep 2019 11:28

Does this module integrated

Does this module integrated with CKEditor widget, and limits length in it too?

Add new comment