Skip to content

Instantly share code, notes, and snippets.

@mdtaju
Created July 12, 2021 10:00
Show Gist options
  • Save mdtaju/290de89e2662ec51ac8907479c41e4b5 to your computer and use it in GitHub Desktop.
Save mdtaju/290de89e2662ec51ac8907479c41e4b5 to your computer and use it in GitHub Desktop.
import { useState } from 'react';
import './App.css';
function App() {
const [Name, setName] = useState('')
const [Email, setEmail] = useState('')
const [Password, setPassword] = useState('')
const SubmitHandler = (event) => {
event.preventDefault()
event.target.reset()
const GetData = {
Name,
Email,
Password
// Shortcut, It's mean - Name: Name, Email: Email, Password: Password
}
console.log(GetData)
}
return (
<div className="App">
<form onSubmit={(e)=>SubmitHandler(e)}>
<h1>Example of getting data from input</h1>
<input type="text" placeholder='Your Name' className='FormInput' onBlur={(e) => setName(e.target.value)} required/>
<input type="email" placeholder='Your Email' className='FormInput' onBlur={(e) => setEmail(e.target.value)} required/>
<input type="password" placeholder='Your Password' className='FormInput' onBlur={(e) => setPassword(e.target.value)} required/>
<input type="submit" value="SUBMIT" className='FormSubmit'/>
</form>
</div>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment