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

forminput

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)
21 views1 page

forminput

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
You are on page 1/ 1

import {useState} from 'react';

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy