Need some help with your project? Contact me

Cool Module: Maxlength

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.

Some related articles you might enjoy

Comments

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.

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!

I think Maxlength module is best.

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.

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!

Add new comment

You must have Javascript enabled to use this form.