0

I was trying to add basic validation to the TextFieldStyled from material UI box and I am using React-form-hook for this.

            <TextFieldStyled
              label='LAN*'
              id='outlined-basic'
              variant='outlined'
              defaultValue=''
              {...register('lan1', {
                onChange: (e) => setValue('lan1', e.target.value.trim(), { shouldValidate: true }),
                required: 'Please enter LAN',
                minLength: { value: 10, message: 'LAN should have at least 10 character.' },
                maxLength: { value: 50, message: 'LAN should not be more than 50 characters.' }
              })}
            />`your text`

but whenver I am typing any value it is getting off focus (may be it is unmounted) the value of error is comming correct but the input is getting off focused.and I have to click on it again to type the next word.``

  • Does this answer your question? [React Hooks - Input loses focus when 1 character is typed in](https://stackoverflow.com/questions/59715158/react-hooks-input-loses-focus-when-1-character-is-typed-in) – kca Mar 18 '23 at 16:41

0 Answers0