faqts : Computers : Programming : Languages : JavaScript : Forms : TextAreas/TextFields

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

64 of 124 people (52%) answered Yes
Recently 2 of 10 people (20%) answered Yes

Entry

Can I protect a text field/text area against pasting in text (Ctrl-V or right click->paste)?

May 16th, 2001 14:00
Robert Taylor, Martin Honnen, T Hildebrandt,


In IE4+ and NN6 you can make a text field or textarea read only by 
setting
  <INPUT TYPE="text" NAME="fieldName" READONLY>
or with js
  document.formName.fieldName.readOnly = true;
This prevents pasting of text into the text field.
I don't know of a way to prevent it with NN3, NN4, or IE3.
For a cross-browser solution, use the technique described here:
http://faqts.com/knowledge_base/view.phtml/aid/868/fid/130