Monday, 26 March 2012

How to restrict ctrl+v in textbox?

The simplest way to restrict ctrl+v in textbox is,
declare onpaste, oncopy, oncontextmenu attributes in body.
Ex:
<body onpaste="return false" oncopy="return false" oncontextmenu="return false">
........
</body>

the above will restrict ctrl+v, ctrl+c, right click in all textbox's.

To restrict ctrl+v in individual textbox,

<input type="text" onpaste="return false" oncopy="return false" oncontextmenu="return false">

onpaste : restricts ctrl+v
oncopy : restricts ctrl+c
oncontextmenu : restricts right click in textbox

No comments:

Post a Comment