How to allow only numbers in textbox in reactjs?

Posted by Jessica Taylor | Updated on

Want to allow only numbers in textbox in reactjs? Use controlled component (use value and onChange property of input field), and inside onChange handle check whether the entered value is proper number or not. Update the state only when entered value is a valid number.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers