Sometimes we need to restrict the user to cut or copy the content from TextBox and also restrict to paste the content into TextBox. It is very easy to do this using Java Script as well as using Jquery. Here I will show you both the methods i.e. using Java Script and using jQuery.
That's it. :)
Using Java Script
<asp:TextBox ID="txtByJavaScript" runat="server" oncut="return false;" oncopy="return false;" onpaste="return false;"></asp:TextBox>
Using Jquery
<script type="text/javascript">
$(document).ready(function () {
$('#txtByJquery').bind('cut
copy paste', function (e) {
e.preventDefault();
//disable cut,copy,paste
});
});
</script>
That's it. :)
No comments:
Post a Comment