Contenteditable attribute does not work

Asked

Viewed 37 times

4

<input type="email" name="email-empresa" id="email-empresa" placeholder="ex: seuemail@domínio.com" class="txt-input" contenteditable="false" value="[email protected]">

I’m having trouble making the input content not editable, because, later, the input value will be placed via php, and the user will not be able to edit your email unless it is an Adm of the site

2 answers

3


contenteditable="false" apparently it doesn’t work in input, do so (readonly)

<input type="email" name="email-empresa" id="email-empresa" placeholder="ex: seuemail@domínio.com" class="txt-input" readonly value="[email protected]">

So you can still position the cursor there, but if you don’t want you can always put disable:

<input type="email" name="email-empresa" id="email-empresa" placeholder="ex: seuemail@domínio.com" class="txt-input" disabled value="[email protected]">

  • perfect, worked at first

  • 1

    Good to see @Murilogambôa.

2

Just add the attribute readonly.

<input type="email" name="email-empresa" id="email-empresa" placeholder="ex: seuemail@domínio.com" class="txt-input"  value="[email protected]" readonly>

Read more about the attribute readonly in: HTML readonly Attribute

Browser other questions tagged

You are not signed in. Login or sign up in order to post.