screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script> <script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script> <script src="https://unpkg.com/@babel/standalone@7.14.7/babel.min.js"></script> </head> <body> <div id="app"></div> <script type="text/babel"> const { useState } = React; function App() { const [password, setPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); const validateForm = () => password === confirmPassword; return ( <div className='container'> <h3 className='header'>React Js Confirm Password Validation</h3> <div> <p className='label'>Password</p> <input className='password-input' type="password" value={password} onChange={(e) => setPassword(e.target.value)} /> <p className='label'>Confirm Password</p> <input className='confirm-password-input' type="password" value={confirmPassword} onChange={(e) => setConfirmPassword(e.target.value)} /> {confirmPassword && ( <p className='validation-message' style={{ color: validateForm() ? "green" : "red" }} > {validateForm() ? "Password Match" : "Password Does not Match"} </p> )} </div> </div> ); } ReactDOM.render(<App />, document.getElementById("app")); </script> <style> .container { max-width: 400px; margin: 0 auto; padding: 20px; border-radius: 5px; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.24); } .header { font-size: 24px; text-align: center; margin-bottom: 20px; } .label { font-size: 16px; margin-bottom: 8px; } .password-input, .confirm-password-input { width: 100%; padding: 10px; font-size: 16px; border: 1px solid #ccc; border-radius: 5px; margin-bottom: 10px; transition: border-color 0.3s ease-in-out; box-sizing: border-box; } .password-input:focus, .confirm-password-input:focus { outline: none; border-color: #007bff; } .validation-message { font-size: 14px; margin-top: 5px; } </style> </body> </html>