How to set input box to be a floating number in ReactJS ? Last Updated : 06 Nov, 2023 Comments Improve Suggest changes Like Article Like Report When working with forms in ReactJS, you may encounter scenarios where you need to accept floating-point numbers as input from users. We will set an input box to accept floating numbers in ReactJS and handle the validation of the entered values. PrerequisitesReact JS NPM and Node.jsApproach If we want to set the input box to be a floating number then we can use the step attribute of the input tag. We have to set the input type as the number and step value by which we want to increase/decrease the floating number. Steps to create React ApplicationStep 1: Create a React application using the following command npx create-react-app foldernameStep 2: After creating your project folder i.e. foldername, move to it using the following command: cd foldernameProject Structure: Example: This example implements input box for a floating number input. JavaScript import React from "react"; class App extends React.Component { state = { value: 10, }; onValueChange = (event) => { this.setState({ value: event.target.value }); }; render() { return ( <div style={{ textAlign: "center", margin: "auto", }} > <h1 style={{ color: "green" }}> GeeksforGeeks </h1> <h3> React Example for Input Box with floatin number </h3> <label> Floating Number: </label> <input type="number" step="0.1" min="0" max="20" value={this.state.value} onChange={(event) => this.onValueChange(event) } /> <h4> Current input value is {this.state.value} </h4> </div> ); } } export default App; Step to Run the App: use this command in the terminal in the project dirctory. npm startOutput: This output will be visible on the http://localhost:3000/ on the browser window. Comment More infoAdvertise with us Next Article How to set input box to be a floating number in ReactJS ? K KapilChhipa Follow Improve Article Tags : Web Technologies ReactJS React-Questions ReactJS-Basics Similar Reads How to Reset a File Input in React.js ? To reset a file input in React JS, we can use the useRef Hook to create a reference to the input element and modify its properties using the DOM API.Prerequisites:NPM & Node JSReact JSReact useRef HookApproach:To reset a file input in react we will create a reset button and handleReset function. 2 min read How to add Floating Buttons in React Native ? React Native is an open-source UI software framework created by Meta Platforms, Inc. It is used to develop applications for Android, Android TV, iOS, macOS, tvOS, Web, Windows, and UWP by enabling developers to use the React framework along with native platform capabilities.In this article, we will 2 min read How to create a translucent text input in ReactJS ? We are going to learn how to create a translucent text input in React JS. We are going to create a translucent animated text input using framer-motion and styled components.Prerequisites:JavaScript (ES6)React JSReact useStatestyled-componentsframer-motion Approach: We are going to create a transluce 4 min read How to decrease input height with floating labels in React-Bootstrap? React-Bootstrap is a front-end framework that was designed keeping React in mind. Let's learn a little bit about floating labels. Floating labels are the form labels that float over the input fields. For creating floating labels, we wrap <Form.Control> element inside <FloatingLabel>. In 3 min read How To Handle Multiple Input Field In React Form With A Single Function? When building a form in React, especially one with multiple input fields, itâs essential to maintain clean, readable code. A common approach is using a single function to handle all input fields, reducing redundancy and enhancing efficiency. This article will explore how to handle multiple input fie 4 min read How to add Phone Number Input in React.js ? Phone Number Input in React JS includes features like country code and number validation. It is an important part when you are creating a form input with a Phone number as the input field. Approach to Add Phone Number Input in React JS To add our phone input we are going to use the react-phone-input 2 min read How to create Price Range Selector in ReactJS? Price Range Selector means the user is able to select the range between the given values. Material UI for React has this component available for us and it is very easy to integrate. Price Ranges Selectors is a very popular feature for filter the results on the basis of the range selected by the user 2 min read How to Change an Uncontrolled Input in React? Uncontrolled input refers to form elements such as text fields, checkboxes, or radio buttons, where the value isn't directly managed by the React state. Their values are stored within the DOM itself and are independent of the React state. It can be challenging to change their input. In this article, 2 min read How to add AutoSize Input in React.js ? We are going to learn how we can add AutoSize input in ReactJs. React is a free and open-source front-end JavaScript library for building user interfaces or UI components. Prerequisites:Nodejs and NPMReact JSApproach:  To add our autosize input we are going to use the react-input-autosize package. T 2 min read How to restrict user character input limit in ReactJS ? To restrict the user character input limit in React JS we can simply set a max input limit to the input box or we can also monitor the input length and make a custom function to set the restriction. Pre-requisite:NPM & Node.jsReact.jsReact HooksHTML onchange EventApproaches to restrict user char 3 min read Like