I want to set the maxlength of a textbox field. i.e <input type="text" id="username" name="username" maxlength="10">
I cannot see where I can set the property. Please advise?
Last I checked, Anvil’s components don’t have such a property. If you’re using them, you could enforce it via a function triggered by the component’s Events. See
Anvil Components The Anvil User Interface is made up of components. Even Forms are a special kind of component.
Some components display information to the user, such as Labels and Images. Others take user input, such as TextBoxes and Buttons.
You...
Here is GREAT library for input validation:
We’ve just released a new module in anvil-labs called zod
It’s very much inspired by the popular TypeScript equivalent zod.dev
It’s not tied to the UI so can be integrated with existing UI solutions
And since it’s not tied to the UI you can use the same validation on the server and client!
Documentation
Quick Start:
>>> from anvil_labs import zod as z
>>> email_schema = z.string().strip().email()
>>> email_schema.parse("foo@bar.com")
# "foo@bar.com"
>>> email_schema.parse(" foo@bar.com "…
1 Like