Module Description
Trim strips all leading and trailing whitespace from all fields in all form submissions.

The module trims prior to validation, so for instance if you have an integer field and a person entering data fat-fingers a space after a number, he gets a successfully saved node rather than an error message about invalid input.

Because blank spaces are likely trimmed or invisible in rendered HTML, you are most likely to see the corrective effects of this module in alphabetical lists such as from Views. So if the proprietor of We Didn't Think Alphabetical Order Mattered On The Internet tries to jump ahead of Aardvark Agency in your directory, she'll be disappointed.

Trimming all form entries everywhere behavior may be a tad aggressive (for instance, if you have an options selection where you've made a key a single ' ' for some reason, or want to allow leading or trailing spaces on a field), but note that Drupal already trims whitespace from passwords without warning, so Trim just extends this behavior to all fields.

Trim module is based on (read: taken in its entirety) from exratione's blog post, Drupal: Trim All Form Fields Everywhere. Exratione has blessed contributing the code here and therefore deserves all credit if this module saves your sanity by sanitizing all stray spaces in your users' input. If it blows up your site file a ticket for me.

Note again that it trims values prior to saving, so it is in fact changing what people enter. This seems a reasonable exception to Drupal's rule of not messing with user input and doing all adjustments on output.

Again, credit to Exratione.

Caveat

* Trim uses Drupal's Form API, and will not affect anything that bypasses the Form API, such as using the REST API.

Image credit: WikiMedia Commons

Project Usage
1644
Creation Date
Changed Date
Security Covered
Covered By Security Advisory
Version Available
DEV
Module Summary
The Trim module solves the issue of leading and trailing whitespace in form submissions by trimming all fields prior to validation, ensuring accurate data entry and preventing errors in alphabetical lists.
Data Name
trim

OPENAI CHATBOT

OPENAI CHATBOT

14:35:16
Generic Chatbot
Hi, I'm a Drupal module expert powered by OpenAI, answering your questions about the Drupal module ecosystem. How can I be helpful today? Please note that we will log your question.