Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Text imput] Limit text example #167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/gdevelop5/objects/text_input/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@ You can set, either from the object properties or using actions, the field as :

* Read-only. Text can still be selected and usually the appearance of the field does not change, but the text can't be modified.
* Disabled. Text usually can't be selected, nor modified, and some devices or platforms will gray the input.

## Limit the text the user can write

You can limit the characters in a text input field by setting a maximum number of characters allowed for input. This is typically achieved by implementing a condition that checks the length of the input text against the specified limit, preventing further input when the limit is reached.

You can limit the text input using the following expression: ***StrLength(TextInput.Text()) < [numeric_variable]***.
![TextInputExample](https://github.com/GDevelopApp/GDevelop-documentation/assets/58533713/10266e06-f7a4-4cd1-bfc0-14eec04f0825)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd simply remove the image and use a code syntax for the expression, because first the image is small, and take place for something that can just be text.

For code you can use this syntax:
Maybe you should rephrase by giving an example, here with 10max characters.

StrLength(TextInput.Text()) <= 10