How do I prevent someone from pasting in a textbox?

How do I prevent someone from pasting in a textbox?

  

Hi there,


I would like to disable the paste function on a textbox, as far as I can I have no idea how to do this, please assist.


Thanks

Tjaart,

You can easily google to get some JavaScript samples of how to achieve this. Not though that it's very bad usability and your users will hate you.

 $('yourtextboxRuntimeid').bind("cut copy paste",function(e) {
     e.preventDefault();
 });

Niels Favreau wrote:

 $('yourtextboxRuntimeid').bind("cut copy paste",function(e) {
     e.preventDefault();
 });

Thanks for this, but as a total newbie, how would I apply the code to a Textarea?


Solution

Hi Tjaart, 


You will find an OML in attach. You will see how it's done. (avoiding the right click paste funtion aswel)

Quick recap :

- Create an expression with escape content to 'no'. (drag it wherever you want)

- In the expression, you will have to write <script type="javascript"....

- In the script, call the document.ready function. 

- Reference your textbox runtime id. (this will be translated automaticly to the html id of the element)

- Disable the paste function


Greetings,

Niels

Solution

Thanks