0

I'm trying to create a text box mixture of HTML/CSS/JS. My requirement is that when I click on text its completely selected and can be copied but no one can change it when posted in blog. It looks like this: Clickable box Help me please.! Thanks in advance. I need complete code combination of HTML/CSS/JS. I am a beginner however the alternate of this question is given in the link but there is need some improvement in my case that no one could be able to delete the text inside it. If some one could be able to design same box as I provided in 1st link, then It'll be great. Thanks once again.!

Community
  • 1
  • 1
  • Possible duplicate of [Select all contents of textbox when it receives focus (JavaScript or jQuery)](http://stackoverflow.com/questions/480735/select-all-contents-of-textbox-when-it-receives-focus-javascript-or-jquery) – Vivek Doshi Apr 01 '17 at 17:17
  • Well once it's posted in the DB I assume. You'd have to implement an edit function to be able to adjust the string. – Marco V Apr 01 '17 at 17:23
  • @emporio No need of DB, just put a text on run time inside a post. – Muhazzab Chouhadry Apr 01 '17 at 17:37
  • @VivekDoshi this is not that question as you suggested, I explain it more briefly please re-read it and give me a better solution. Thanks.! – Muhazzab Chouhadry Apr 01 '17 at 17:38

1 Answers1

0

You can add this.select() to a onClick. That will make sure, that the whole text is selected, whenever you click your input. Adding readonly attribute will make sure, that user isn't going to be able to edit the text.

<input onClick="this.select();" value="Sample Text" readonly/>
Nelala_
  • 301
  • 2
  • 9
  • @Potatolng I need complete code combination of HTML/CSS/JS. However your answer is also correct but in my case text could not be deleted. For example if I write a post and put some links/text inside that textbox and when I publish it then people can only view/select/copy the link/text only. Although it is not going to delete completely. Thanks.! – Muhazzab Chouhadry Apr 01 '17 at 17:44