Next.js Discord

Discord Forum

Shadcn <Input> with type="number" returns string

Answered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
Did anyone have the same issue? Why does the input always return a string, even when I set the type to number?
Answered by Black Turnstone
It is the normal behaviour, type="number" is for devices with virtual keyboard to show numpad instead of whole keyboard.
View full answer

6 Replies

@West African Lion Did anyone have the same issue? Why does the input always return a string, even when I set the type to number?
Black Turnstone
It is the normal behaviour, type="number" is for devices with virtual keyboard to show numpad instead of whole keyboard.
Answer
Black Turnstone
Yes
If you are using zod and input in form you can do something like this in your zod schema.
const input = z.coerce.number()
Rose-breasted Grosbeak