0% found this document useful (0 votes)
51 views1 page

Input Form Validation in React

The document is a React component that manages a simple input form for a name. It uses the useState hook to handle the input state and provides a submit button that alerts the name and checks its validity based on length. The component also displays the name entered by the user below the input field.

Uploaded by

Suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views1 page

Input Form Validation in React

The document is a React component that manages a simple input form for a name. It uses the useState hook to handle the input state and provides a submit button that alerts the name and checks its validity based on length. The component also displays the name entered by the user below the input field.

Uploaded by

Suresh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import {useState} from 'react';

function App() {
const [input , setInput] = useState({ name: '' })
const inputsHandler = (e) =>{ setInput( {[[Link]]: [Link]} )
}
const submitButton = () =>{
alert([Link])
if([Link]>5)
[Link]("valid")
else
[Link]("Invalid")
}
return ( <div>
<div> <input type="text" name="name"
onChange={inputsHandler}
placeholder="Name"
value={[Link]}/>
<br/>
<button onClick={submitButton}>Submit Now</button>
</div>
<br></br>
<div>Name given by you : {[Link]}</div>
</div>
)
}
export default App;

You might also like