LoginForm.jsx 632 B

12345678910111213141516171819
  1. import React, {useState} from "react";
  2. export const LoginForm = () => {
  3. const [login, setLogin] = useState('')
  4. const [password, setPassword] = useState('')
  5. const onLogin = () => {
  6. return !(login !== '' && password.match(/^[A-Za-z]\w{5,10}$/));
  7. }
  8. return (
  9. <>
  10. <div className="loginBox">
  11. <input type="text" value={login} onChange={(e) => setLogin(e.target.value)}/>
  12. <input type="password" value={password} onChange={(e) => setPassword(e.target.value)}/>
  13. <button disabled={onLogin()}>Log In</button>
  14. </div>
  15. </>
  16. )
  17. }