[feature] Text input that accepts only numbers (or validation regex?) #4744
Replies: 3 comments 3 replies
-
go for this |
Beta Was this translation helpful? Give feedback.
-
I would like to see extensions on both of your ideas:
|
Beta Was this translation helpful? Give feedback.
-
While not an explicit solution to client-side validation, I could also see augmenting #4615 with the ability to responding to a I would also like to see field subheaders. Headers + subheaders could be used to communicate what type of input is acceptable, then the dev can validate however they want when the form is submitted, updating the modal with errors on what components are invalid and why. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be a neat idea to have input components for modals that only accept numbers as input.
Possible solutions
Have a new text input component type that would accept only numbers as input and would ignore non-numeric character input (similar to INTEGER Application Command Option Type).
Allow passing a validation regex for a Text Input component. In other words, when the modal submit button is pressed, the input would be checked against your validation regex and display an error to the user if it failed. For example, I could set the regex to something like
[+-]?\d+
to only accept input in that form (optional plus or minus followed by one or more digits).The first solution is a simple solution and would likely be more accessible to bot developers.
The second solution, however, would be more flexible and usable in more situations.
Beta Was this translation helpful? Give feedback.
All reactions