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

Text

Form site

Uploaded by

Umar Farooque
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)
8 views1 page

Text

Form site

Uploaded by

Umar Farooque
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 logo from './logo.

svg';
import './App.css';
import {useState} from 'react'
function App() {
const [name,setName]=useState("");
const [tnc,setTnc]=useState(false);
const [interest,setInterest]=useState("");
function getFormData(e)
{
console.warn(name,tnc,interest)
e.preventDefault()
}
return (
<div className="App">
<h1>Handle Form in React</h1>
<form onSubmit={getFormData}>
<input type="text" placeholder="enter name" value={name}
onChange={(e)=>setName(e.target.value)} /> <br /><br />
<select onChange={(e)=>setInterest(e.target.value)}>
<option>Select Options</option>
<option>Marvel</option>
<option>DC</option>
</select> <br /><br />
<input type="checkbox" onChange={(e)=>setTnc(e.target.checked)}
/><span>Accept Terms and conditions</span>
<br /><br />
<button type="submit">Submit</button>
<button>Clear</button>

</form>
</div>
);
}

export default App;

You might also like