Next.js Discord

Discord Forum

OnChange issue

Answered
Savannah posted this in #help-forum
Open in Discord
SavannahOP
Hey, so im using <Input> it works perfect, but when i am using onchange and value it just only allows one or 2 characters.
Answered by B33fb0n3
you need to first call your function. And the way you doing it rn is wrong.
- onChange={handleInputChange(setUtmMedium)}
+ onChange={() => {handleInputChange(setUtmMedium)}}

That way it should work fine
View full answer

15 Replies

@Savannah Hey, so im using <Input> it works perfect, but when i am using onchange and value it just only allows one or 2 characters.
you need to first call your function. And the way you doing it rn is wrong.
- onChange={handleInputChange(setUtmMedium)}
+ onChange={() => {handleInputChange(setUtmMedium)}}

That way it should work fine
Answer
happy to help
i would be very surprised if that actually worked
- onChange={handleInputChange(setUtmMedium)}
+ onChange={(e) => {handleInputChange(setUtmMedium(e)}}
not this one?
@Savannah Thank you.
did it really work?
@James4u did it really work?
SavannahOP
Not sure I wasn’t on pc I’m trying it today
@Savannah Hey, so im using <Input> it works perfect, but when i am using onchange and value it just only allows one or 2 characters.
after reading your issues again, I think original one was okay I mean
onChange={handleInputChange(setUtmMedium)} is fine I guess
maybe some logic is limiting the length?
SavannahOP
I’ve got no logics in place to limit length I’ll send screen recording if above doesn’t work.
SavannahOP
<Input
type="text"
id="utmMedium"
placeholder="Enter UTM Medium (e.g., social)"
value={utmMedium}
onChange={(e) => {
setUtmMedium(e.target.value);
}}
/>
thats my code and it does that
@James4u not sure if ping's are allowed, i hope it is.