Home
Categories
HTML Select
CSS Class
General
CheckBox
HTML Textarea
DropDown
jQuery UI
DatePicker
Facebook
HTML Form
HTML DIV
ASP.Net
JSON
Radio
Regular Expressions
HTML Multiselect ListBox
HTML TextBox
RadioButtonList
CheckBoxList
HTML Anchor
Master Pages
HTML5
Bootstrap
Image
FileUpload
HTML Span
ListBox
jQuery
Table
Button
Password TextBox
Sponsored
XML
Forums
Contact
Search
Search
Home
Categories
Forums
Contact
Search
Disable Cut Copy and Paste and in TextBox and TextArea using jQuery
26 Mar 2012
Mudassar Khan
0
Comments
12220 Views
HTML Textarea
ASP.Net
HTML TextBox
Follow @jQueryFaqs
Follow @jQueryFaqs
Here Mudassar Ahmed Khan has explained how to cancel or prevent or disable cut, copy and paste operations using jQuery for HTML and ASP.Net TextBoxes and TextArea controls.
Follow @jQueryFaqs
Follow @jQueryFaqs
The below code snippet explains how to disable or prevent cut, copy and paste operations in HTML and ASP.Net TextBox and TextArea using jQuery
<
html
xmlns
="http://www.w3.org/1999/xhtml">
<
head
>
<
title
></
title
>
<
script
type
="text/javascript"
src
="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></
script
>
<
script
type
="text/javascript">
$(
function
() {
$(
".disable"
).bind(
"paste cut paste"
,
function
(e) {
e.preventDefault();
return
false
;
});
});
</
script
>
</
head
>
<
body
>
<
form
id
="form1"
runat
="server">
ASP.Net
<
br
/>
<
br
/>
<
asp
:
TextBox
ID
="TextBox2"
runat
="server"
CssClass
="disable"></
asp
:
TextBox
><
br
/>
<
br
/>
<
asp
:
TextBox
ID
="TextBox1"
runat
="server"
TextMode
="MultiLine"
CssClass
="disable"></
asp
:
TextBox
><
br
/>
<
br
/>
<
br
/>
HTML
<
br
/>
<
br
/>
<
input
type
="text"
class
="disable"
/><
br
/>
<
br
/>
<
textarea
class
="disable"
rows
="5"
cols
="5"></
textarea
>
</
form
>
</
body
>
</
html
>
Explanation:
In the above code snippet in the document ready event I have bind the event handler for cut, copy and paste operations in which I simply cancel the event.
Demo:
ASP.Net
HTML
Related Articles
Maxlength Validation in HTML TextArea using jQuery
Here Mudassar Ahmed Khan has explained how to do maxlength validation in textarea using jQuery
Highlight Form Fields like Textbox, Dropdown and TextArea on focus using jQuery
Here Mudassar Ahmed Khan has explained how to highlight i.e. change border color, background color, etc of the form fields fields like HTML input textbox, input password, select dropdown and textarea on focus and make them normal when lost focus using jQuery and CSS.
Display Watermark Text for HTML INPUT TextBox, Password and TextArea fields using jQuery Plugin
Here Mudassar Ahmed Khan has explained how to apply WaterMark Text for HTML INPUT TextBox, Password and TextArea fields using jQuery Plugin
Comments
No comments have been added to this article.
Add Comments
Thank you for the feedback. The comment is now awaiting moderation. You will be notified via email when the author replies to your comment.
Please select a comment to reply
You can add your comment about this article using the form below. Make sure you provide a valid email address
else you won't be notified when the author replies to your comment
Please note that all comments are moderated and will be deleted if they are
Not relavant to the article
Spam
Advertising campaigns or links to other sites
Abusive content.
Please do not post code, scripts or snippets.
Follow @jQueryFaqs
Follow @jQueryFaqs
Name
Required
Email
Required
Invalid Email Address
Comment
Required
Security code:
Required
Invalid security code.
Add Comment
Message from Author
Message from Author
Subscribe
Follow @jQueryFaqs
Follow @jQueryFaqs
Error Details
Disclaimer
This site makes use of Cookies. Please refer
Privacy Policy
for more details.