Limit Textbox Response Length

I am looking for a way to limit the length of responses a participant can type into a textbox. In the task I am working on, they need to be able to only type up to 2 characters, with a minimum of 1.

I have an “each frame” code setup to limit what buttons they can respond with (numerical keys). Is there a way to code for if textbox.length < 2 stop inputting?

You could try

if len(textbox.text) > 2:
     textbox.text = textbox.text[0:1]
1 Like

It ended up being

if len(textbox.text) > 2:
     textbox.text = textbox.text[0:2]

[0:1] would delete down to a length of 1. Thank you for the help (again!)