How to set the attribute "maxlength" to a textinput

i want to limit the input size in one text input field
Is this possible with the ui_template or do i have to use st else?


The two fields "nickname pick-up" and "ID (Card)" have to be limited.

Hi - no you can't set the max width - sorry. You would have to recreate the whole form with a template instead.

is there any other way
for example: changing the color if the input number of chars is higher then the maximum length?
or sth else?

One thing you can do easily is wait for the user to submit the input and then check it for validity. If the strings are too long, you don't pass the input along but instead prompt the user for shorter ones. This flow is a crude example:

[{"id":"4c76b829.644aa","type":"ui_form","z":"21415eb.4206da2","name":"","label":"","group":"58239138.4af19","order":3,"width":0,"height":0,"options":[{"label":"5 character maximum","value":"max5","type":"text","required":false,"rows":null},{"label":"7 character maximum","value":"max7","type":"text","required":false,"rows":null}],"formValue":{"max5":"","max7":""},"payload":"","submit":"submit","cancel":"cancel","topic":"","x":410,"y":140,"wires":[["d7ac73a1.858a78"]]},{"id":"c283b516.43f68","type":"debug","z":"21415eb.4206da2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":690,"y":80,"wires":[]},{"id":"d7ac73a1.858a78","type":"function","z":"21415eb.4206da2","name":"verify","func":"let msg2 = {}\nlet len1 = msg.payload.max5.length\nlet len2 = msg.payload.max7.length\nif (len1 < 5 & len2 < 7){\n    node.send([msg,null])\n} \nif (len1 > 5){\n    msg2.payload = {max5:\"input too long\"}\n    node.send([null,msg2])\n}\nif (len2 > 7){\n    msg2.payload = {max7:\"input too long\"}\n    node.send([null,msg2])\n}\n","outputs":2,"noerr":0,"x":530,"y":80,"wires":[["c283b516.43f68"],["4c76b829.644aa"]]},{"id":"58239138.4af19","type":"ui_group","name":"Group 2","tab":"1b0057e0.037f48","order":2,"disp":true,"width":6},{"id":"1b0057e0.037f48","type":"ui_tab","z":"","name":"Test","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

In any case, it's always a good idea to check user input for validity and sanity.