onChange event not firing when typing
See original GitHub issueThe onChange
event only seems to fire when selecting a date from the picker but not when the user types into the input field. This makes it impossible to do any sort of validation on user input.
Current workaround is to set readOnly
to true
so that it forces users to only use the picker, but it would be ideal to also let them type into the box and be able to run my own validation regex in a change handler before updating the input value. Am I missing something here or is this not supported? It seems like you would either need to expose the input field’s actual onChange
property or tie it into the parent component’s property (I would have assumed it already was).
React-datepicker v0.25.0 React v0.14.7
Issue Analytics
- State:
- Created 7 years ago
- Reactions:11
- Comments:11
Top Results From Across the Web
html <input type="text" /> onchange event not working
I am trying to do some experiment. What I want to happen is that everytime the user types in something in the textbox,...
Read more >Text edit onchange not firing when typing
This might be happening because the OnChange property of a text input, gets triggered when you click outside of the control, somewhere else...
Read more >The attribute for input tag"onchange" will not fire, but ...
onchange is only triggered when the control is out of focus. That means you have to click outside of the input field after...
Read more >HTMLElement: change event - Web APIs | MDN
Unlike the input event, the change event is not necessarily fired for each ... where the user's interaction is typing rather than selection, ......
Read more >HTML onchange Event Attribute - W3Schools
The onchange attribute fires the moment when the value of the element is changed. Tip: This event is similar to the oninput event....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I noticed that
onChange
event never happens if using custom input component with null value. When we select date through DatePicker the input field first getonBlur
event and then if it’s value isnull
andonBlur
handler of input element is defined thenonChange
of DatePicker is not fired.I met the same issues in my practice so I resolve problem with this approach - just pass all props(value, onClick, onChange) in the custom input(child) component: