I am new to Javascript and trying to write a program to prevent text from being copied into textfield. the following is my code
function dontpaste()
{
alert("hello");
return true;
}
<input type="text" name="name" id="name" onpaste="dontpaste()">
The method is getting called. But the text gets copied after alert. Even
document.getElementById('name').value="";
is not working. Even tried with
return false;
for the method, still the text gets copied.
What needs to be done so that the method is called but text is not copied?