Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Can you, via JavaScript or such, prevent dragging and dropping into a textarea or an Input with type=text?
Is there a way, to prevent a user from dragging and dropping something into a textarea or an input field with type=text
I've searched around - for quite a while - tried some things I've found but have not succeeded in preventing a drop.
I can prevent user enter in the item by using the onFocus to call blur() but I can't prevent a drop.
I did find an article on MDC but it speaks to configuring your browser, not doing something to prevent dropping on a web page you are creating.
That is at https://developer.mozilla.org/en/Mozill ... support.3f
Another question - is there a way to make an image a drop target? I want to do it to trigger the drag/drop events and then handle whatever is dropped myself.
Another - If a user drags and drops something to a textarea or input type=text, is there a way to cause the dropped text (or whatever) to replace everything that is already in the textarea of input type=text. I've tried a few things but the dropped text is always added to the existing text, at the point the cursor is when you release the mouse button to do the drop.
I want to totally prevent a user from highlighting something on the web page and then dragging it and dropping it into particular textareas or input field with type=text
By default,, almost all browsers let you do this. On a web page with a text input area, highlight some text and drag it to the input area and drop it - the text should be added to the input areal.
----
Ah, I'm not worried, at this point, about someone pasting into the field. I want to prevent drag and drop operations - a totally different type of animal.
Besides, I have think I eliminated paste operations by setting the onfocus event to call blur() for the object. You can't paste into something that you cannot set the focus to.
1 Answer
- just "JR"Lv 71 decade agoFavorite Answer
Try this (in the <head> part of your page)
<script src="jquery.js"></script>
<script type="text/javascript">
$(function()
{
$('input[id$=_re]').bind('cut copy paste', function(e) {
e.preventDefault();
alert('Paste Function Prohibited'); });
});
</script>
Google and download jsquery.js at http://jquery.com/
Your inputs with "text" where you don't want copy/paste must have ids of the form:
<input type=\"text\" id=\"email_re\" ... ( _re at the end)
(Sorry, one question at a time)