how to make an input field that only allows numbers ?

that's an very beginner question. How to only allow number's in an input field BUT with out the usage of dedicated Signal's for an field or anything really complicated ? (I am using TypeScript ) It would also have to include float numbers
17 Replies
Eve
Eve2mo ago
google "html input numbers only"
⛤ND⛤
⛤ND⛤OP2mo ago
that's not really usefull i tried to find somehting but none of the solutions are really "working" or are not applicable with Solid js
Eve
Eve2mo ago
But inputs have nothing to do with solid. They're HTML elements.
⛤ND⛤
⛤ND⛤OP2mo ago
the quesiton wa smaybe not correctly said. It's more about using solid in an way to enforce an input field only taking in numerical types nothing else that's not possible in plain html
Eve
Eve2mo ago
yes it is.
Eve
Eve2mo ago
MDN Web Docs
- HTML: HyperText Markup Language | MDN
elements of type number are used to let the user enter a number. They include built-in validation to reject non-numerical entries.
Eve
Eve2mo ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
⛤ND⛤
⛤ND⛤OP2mo ago
NO THIS IS NOT WHAT I MEAN. I have seen tese docs times before, i try to have an input box whihc ONLY allows numerical values which are valid for type conversation, i appreciate the help but it's not what i am looking for , sitll thanks
No description
Eve
Eve2mo ago
look at the playground I sent. You can't type letters into it. (well except e, because 1.2e6 is valid)
⛤ND⛤
⛤ND⛤OP2mo ago
No description
bigmistqke
bigmistqke2mo ago
you might be looking for https://primitives.solidjs.community/package/input-mask i never used it myself tho it has support for a lot more complex input masks, so it's mb a bit of overkill
bigmistqke
bigmistqke2mo ago
the type="number" is enough for chrome
bigmistqke
bigmistqke2mo ago
but not on safari
bigmistqke
bigmistqke2mo ago
any vanilla js solution should work for solid-js too, so maybe you can find a simpler alternative then the input mask
bigmistqke
bigmistqke2mo ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
⛤ND⛤
⛤ND⛤OP2mo ago
thanks, mate. This is more what i was looking a lot of the vanilla solution i found where a bit more over kill than this
bigmistqke
bigmistqke2mo ago
ur welcome!
Want results from more Discord servers?
Add your server