How restricting the number of characters in a input text box?

Hi.
My doubt is that. Can you help me?

Thank you.

Every time the user changes something in the text box it checks if the length of the text is greater then or equal to 5, if it is chop 1 from the left and set the text in the text box. This limits it to 4 characters in said text box.

Edit: I’m pretty sure with this way you could bypass the limit by simply copying in text instead. So you should take the maximum limit - the length of the text > absolute > clamp 1-X and plug that into the “Left Chop” nodes count, that way even if you copy something it should chop it off to the maximum limit.

Edit2: Something like this would work.

5 Likes

Thank you very much, Tekoppar.

Thank you, friends!

An alternative is to just use SubString (still using on the suggested ontextchanged)

Just set length to your maximum allowable size. It will handle 1 or multiple characters.

2 Likes

I also figured out that you can use the substring method and set the text box that is being edited to this string, which will not allow the user to type any more in the text box than the max length of the substring.

This was useful - thanks :slight_smile:

This way i just set limit to 10 character in text box, (bottom) - on thext changed
Then when u press enter i send it to server.
Thanks for help guys :slight_smile:

1 Like

Setting the characters limit to a certain value and chopping everything that will be printed after that:

“Copy>paste” protection included.