how to turn off autocomplete of a form when switching in react form? And why is this happening?
saves the form here and then sends it to the server
const [formR, setFormR] = useState({password: '', repeat: '', login: '', email: ''})
const [formL, setFormL] = useState({password: '', email: ''})
const changeHandlerR = (event:any) => {
return setFormR({...formR, [event.target.name]: event.target.value})
}
const changeHandlerL = (event:any) => {
return setFormL({...formL, [event.target.name]: event.target.value})
}
if(count === 0){
return(<Main>
<SectionAuth>
<section>
<p onClick={() => setCount(count + 1)}>Вход</p>
<p className="active">Регистрация</p>
</section>
<div>
<input type="login" name="login" placeholder="login" onKeyUp={login} onChange={changeHandlerR} required/>
<input type="email" name="email" placeholder="email" onKeyUp={email} onChange={changeHandlerR} required/>
<input type="password" name="password" placeholder="password" onKeyUp={checkPassword} onChange={changeHandlerR} required className="password"/>
<input type="password" name="repeat" placeholder="password" onKeyUp={checkPassword} onChange={changeHandlerR} required className="password"/>
<button type="submit" onClick={registerHandler} className="buttonCheck">Отправить</button>
</div>
</SectionAuth>
</Main>)
}
return(<Main>
<SectionAuth>
<section>
<p className="active">Вход</p>
<p onClick={() => setCount(count - 1)}>Регистрация</p>
</section>
<div>
<input type="email" name="email" placeholder="email" onKeyUp={email} onChange={changeHandlerL} required/>
<input type="password" name="password" placeholder="password" onKeyUp={checkPassword} onChange={changeHandlerL} required/>
<button type="submit" onClick={loginHandler} className="buttonCheck">Отправить</button>
</div>
</SectionAuth>
</Main>)
}
When switching in a form, another form is autocompleted.