Is it possible to limit the number of characters while inputting a string into an input_text helper?
My scenario:
I’m storing a 4 digit lock pin/code in a input_text entity. I have the helper set for a max of four characters, but the when inputting it will still allow me to enter an unlimited number of characters (although it doesn’t accept the input if it’s over 4). I was wondering if it’s possible to make a hard stop to any additional character over 4 when inputting so I (or more likely someone else) tries to input more only to find out later the pin wasn’t accepted.
Thanks for quick reply. That is correct. although I was hoping for a hard stop once I hit the four character limit. Instead it allows me to input a novel. I just figured the "max’ option feature would work that way. Guess not.
What is the input “source”?
If you create a picture elements card with 10 buttons then each button press could add one digit to the input text.
That way you could limit it.
But if the “source” is the entity itself and a keyboard then it’s probably not possible
My input source is straight from the keyboard. The picture elements card is an interesting way to attack the issue, but in this case, more effort than I want to put in for this project. Again, I appreciate the feedback!
Haha…Well I actually thought about that…BUT here’s the rub. I really want the string to be hidden (i.e.password mode with the asterisks instead of visible) and I don’t see a way to do that with the number input. ugh! I can’t win!
There is a video that is probably one or two years old by Rob on the hookup channel where he creates an alarm panel in node red.
I have not used it myself but my memory says it looks like a picture elements card.
As far as I know, input_text doesn’t support that behavior.
All you can do is add a regex pattern like this:
^[0-9]{4,4}$
It still allows you to type whatever you want and as much as you want but will only use what you entered if it contains four numbers (no more, no less). In the UI, the underline is red if the inputted text is invalid and only changes to blue when it’s 4 digits.