Skip to content

Is it possible to register divs with contenteditable=true ? #1710

Answered by linecept
alessiopece asked this question in General
Discussion options

You must be logged in to vote

There is a more complete answer here.

First register your div contenteditable:

 useEffect(() => {
    register(
      { name: 'name' },
      { required: true, maxLength: 75 }
    );
  }, []);

Then inside the div editable do this:

< div 
contenteditable
onInput={(e) => {
  setValue('name', e.currentTarget.textContent, { shouldValidate: true });
}}>contenteditable</div>

Important here is to include the shouldValidate inside the onInput of the div contenteditable.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@alessiopece
Comment options

Comment options

You must be logged in to vote
4 replies
@nobleach
Comment options

@brvnonascimento
Comment options

@RobJJ
Comment options

@evandojunior-hotmart
Comment options

Answer selected by bluebill1049
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants