Tip: Limit the length of a text field

What if you want to limit the number of characters users can type in a text field? This tip uses validation to alert your users if they type too much text and show you how to include only a limited number of text field characters in reports.

Input text fields collect text typed by your users. What if you want to limit the number of characters they can enter? There isn’t a built-in way to do that just yet, but you can achieve something very similar today.

First, you need to associate a formula with the Valid property of your text field to alert your users if they type too much text. The LEN function returns the number of characters in a text string and is perfect for this task. Associate this formula with the Valid property to alert your users if they type more than 20 characters:

LEN(TextField) <= 20

This formula won’t help you actually limit the length of the value. What if you want to include only the first 20 characters in a report? Easy, just use a hidden text field using the following formula:

LEFT(TextField, 20)

Be sure to reference this hidden text field from your report-generating panel instead of the visible field (which contains all the text typed by your users). Refer to this tip to learn more about using a dedicated panel for generating reports which only contain a select number of fields.

Here’s what the finished app looks like running as a preview in Calcapp Creator:

Calcapp Creator demonstrating how to send reports including only certain fields

Do you want to share a tip with other Calcapp users through this blog? Let us know!

« Feature: Apps now load faster Feature: Customize subject lines of reports »