Introduction:
Here
I will explain how to disable drag and drop option in textbox or textarea using
JavaScript properties.
Description:
In previous articles I explained JavaScript show number of characters left, JavaScript restrict user to enter only numbers, JavaScript allow limited characters in textarea, JavaScript remove special characters from textbox and many articles relating to JavaScript, jQuery, asp.net. Now I will explain how to disable drag and drop option in textbox or textarea.
In previous articles I explained JavaScript show number of characters left, JavaScript restrict user to enter only numbers, JavaScript allow limited characters in textarea, JavaScript remove special characters from textbox and many articles relating to JavaScript, jQuery, asp.net. Now I will explain how to disable drag and drop option in textbox or textarea.
Previously
I written one post JavaScript remove special characters from textbox to remove
special characters from textbox at that time one reader has asked me the
question like
“Textbox
removing special characters whenever I enter but if I select some special
characters text and hold the text by mouse click and drop it in textbox it’s
allowing how to restrict that drag and drop option?”
To
stop drag and drop option in textbox or textarea we need to set some of
properties in body tag for that check below
<html>
<head>
</head>
<body ondragstart="return
false" draggable="false">
<b>Try
to Drag and Drop Text Here :</b> <input type="text"
name="txt"
id="txtname"
/>
</body>
</html>
|
Live
Demo
For
live demo try to select some text drag and drop in textbox
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
6 comments :
how to send sms on mobile using asp.net web pages?
how to add tab using asp.net web pages?
how to send sms in asp.net Plz tell me ?
this is not the right way to hadle this drag and drop problem, why because in this scenario we can drag a text from next browser tab and drop here
add this two attributes in the input textbox
'onDrop' => "blur();return false;",
'onpaste' => "return false"
this will avoid the drop and paste in textbox
drop text from outside browser not blocked with this
Note: Only a member of this blog may post a comment.