469,927 Members | 1,965 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Prevent pasting into custom textbox control.

Hi;

I need to create a custom textbox control which will not allow a user
to paste text from the clipboard. The user has to always type the text
into the textbox.

I tried searching on the internet since I guessed someone would have
faced this problem before but of no avail. Do we have pointers on how
I should go about doing this??

Comments\suggestions are highly appreciated.

Kind Regards;

Ajit Goel

Apr 17 '07 #1
2 2095
I can't imagine why you'd want to do this, and it's pretty much not possible
to prevent someone completely from entering data into a textbox the way he
seems fit. In addition to pasting, will you try to prevent the person from
dragging text in? If you capture Ctrl+V with javascript, will you also
capture keyboard buttons that paste without just "sendkey'ing" Ctrl+V? What
about when someone uses something like Roboform to fill the field? Will you
also prevent a right-click so the person can't choose to paste from the
context menu?

I suggest that you eliminate this requirement if at all possible. To put
together a perfect solution is impossible. To put together one that is
close to perfect would be a lot of code to maintain for something very
silly.

Ray at work

"AjitGoel" <aj******@gmail.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
Hi;

I need to create a custom textbox control which will not allow a user
to paste text from the clipboard. The user has to always type the text
into the textbox.

I tried searching on the internet since I guessed someone would have
faced this problem before but of no avail. Do we have pointers on how
I should go about doing this??

Comments\suggestions are highly appreciated.

Kind Regards;

Ajit Goel
Apr 17 '07 #2
Thanks Ray;

I appreciate your input. I guess this thought came in when the BA and
my director told me to explore this option.

On Apr 17, 1:52 pm, "Ray Costanzo" <my first name at lane 34 dot
commercialwrote:
I can't imagine why you'd want to do this, and it's pretty much not possible
to prevent someone completely from entering data into a textbox the way he
seems fit. In addition to pasting, will you try to prevent the person from
dragging text in? If you capture Ctrl+V with javascript, will you also
capture keyboard buttons that paste without just "sendkey'ing" Ctrl+V? What
about when someone uses something like Roboform to fill the field? Will you
also prevent a right-click so the person can't choose to paste from the
context menu?

I suggest that you eliminate this requirement if at all possible. To put
together a perfect solution is impossible. To put together one that is
close to perfect would be a lot of code to maintain for something very
silly.

Ray at work

"AjitGoel" <ajitg...@gmail.comwrote in message

news:11**********************@d57g2000hsg.googlegr oups.com...
Hi;
I need to create a custom textbox control which will not allow a user
to paste text from the clipboard. The user has to always type the text
into the textbox.
I tried searching on the internet since I guessed someone would have
faced this problem before but of no avail. Do we have pointers on how
I should go about doing this??
Comments\suggestions are highly appreciated.
Kind Regards;
Ajit Goel- Hide quoted text -

- Show quoted text -
Apr 17 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Sanjay Pais | last post: by
1 post views Thread by rn5a | last post: by
reply views Thread by rn5a | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.