12345678910111213141516171819202122 |
- import React, {useState} from "react";
- export const LoginForm = ({onLogin}) => {
- const [login, setLogin] = useState('')
- const [password, setPassword] = useState('')
- const checkButton = () => {
- return !(login !== '' && password.match(/^[A-Za-z]\w{5,10}$/));
- }
- const auth = () => {
- onLogin(login, password)
- }
- return (
- <>
- <div className="loginBox">
- <input type="text" value={login} onChange={(e) => setLogin(e.target.value)}/>
- <input type="password" value={password} onChange={(e) => setPassword(e.target.value)}/>
- <button disabled={checkButton()} onClick={auth}>Log In</button>
- </div>
- </>
- )
- }
|