使用react yup库,它超出了它在输入时使用的感叹号以及我用来显示和隐藏密码的图标

问题描述 投票:0回答:0
我正在使用 yup 和 formic 库进行验证,但我有一个问题,我用来显示和隐藏密码的眼睛图标与 yup 验证附带的圆圈中的感叹号冲突。

我不想看到感叹号,我该怎么做?我的代码如下

const [showPassword, setShowPassword] = useState(false); const togglePasswordVisibility = () => { setShowPassword((prevShowPassword) => !prevShowPassword); } const validation = useFormik({ enableReinitialize: true, initialValues: { username: userLogin.username || '', password: userLogin.password || '', }, validationSchema: Yup.object().shape({ username: Yup.string().matches().required("Lütfen kullanıcı adını giriniz."), password: Yup.string().required("Lütfen şifrenizi giriniz."), }), onSubmit: async (values) => { await login(values); }, }); <Label className="form-label" htmlFor="password-input" > Şifre </Label> <div className="position-relative auth-pass-inputgroup mb-3"> <Input name="password" value={validation.values.password || ""} type={showPassword ? "text" : "password"} className="form-control pe-5" placeholder="Şifre" onChange={validation.handleChange} onBlur={validation.handleBlur} invalid={validation.touched.password && validation.errors.password ? true : false } /> {validation.touched.password && validation.errors.password ? ( <FormFeedback type="invalid"> {validation.errors.password} </FormFeedback> ) : null} <button className="btn btn-link position-absolute end-0 top-0 text-decoration-none text-muted password-addon" type="button" id="password-addon" onClick={togglePasswordVisibility} > <i className="ri-eye-fill align-middle"></i> </button> </div> </div>
    
javascript reactjs react-native formik yup
© www.soinside.com 2019 - 2024. All rights reserved.