How to check a text field length

Hi,
I've a text field binding with a tag. The user can insert the text and I want to limit the number of char to 10.
How can I do it? Where can I insert the code? Thanks in advance.

Set up your props by unchecking defer updates and rejectUpdatesWhileFocused.

Then in the onKeyPress event handler add this script. (There may be a better way to handle this, but it works.)

	if len(self.props.text) > 10:
		self.props.text = self.props.text[:10]

1 Like

image
I still have the error : error writing to myTag . Bad Out of range.

What about expression binding with left(value,10) ?

You can't bind the value to itself, that is an infinite loop

Is the tag bound to the text input value, or are you writing the value to the tag with a script? Share more info on your current setup.

thank you for your help, I've resolve using your script and uncheck the bidirectional on the bindign property