By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,572 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,572 IT Pros & Developers. It's quick & easy.

Prevent pasting into custom textbox control.

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.