I’ve been trying various methods to set the maxLength attribute of the input created by New-UDTextbox with no success, including its -Max parameter, or calling Set-UDElement / Invoke-UDJavaScript. If I set the attribute using browser dev tools, it works fine. I just can’t seem to get PSU to set that attribute for the life of me.
The input is in a Stepper, so I know I can simply use validation to enforce the length requirement, but I’d really prefer to have the input at a capped length as well for admittedly aesthetic reasons.
I appreciate the code snippet. I had tried something similar but honestly, I’ll just stick with the enforcement through stepper validation without the extra fuss, as that will also address input less than 7 digits long. Would really be nice to be able to set standard HTML attributes like maxLength on inputs, though.
You can achieve this by using the -mask parameter:
In your case this would be:
New-UDTextbox -Mask "00000000"
The problem? Apparently adam wants to get rid of this parameter which doesnt work with regex as stated in the docs… it only works well with pattern mask…
In addition I realized that if you use -mask the -onvalidate won’t work in conjunction anymore. So unfortunately you can’t have both things together (at least at the moment).
I really hope that -mask will not disapper because based on some use cases I like this one better…