How to set character length (maxlength) for input box/text box

Hi all,

The subject line says it all really. I have created an input box to enter text, but I need to set the maximum amount of characters that someone can type into it, ie. for a name.

input = createInput();
input.position(20,20); etc. etc.

But how do I set the maxlength?

Many thanks.


You may try out method attribute() in order to add maxlength:

input = createInput().attribute('maxlength', maxChars);

1 Like

Thank you very much for the fast reply, very kind.

This solution will be perfect. I was not aware of it.