<input type="text" class="input-prohibit-drop" placeholder="you can not D&D text">
<p>The quick brown fox jumps over the lazy dog</p>
*,
*:before,
*:after {
box-sizing: border-box;
}
body {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100vh;
}
.input-prohibit-drop {
padding: 0.5rem;
width: 20rem;
}
document.querySelector(".input-prohibit-drop").addEventListener(
"drop",
function(e) {
e.preventDefault();
},
true
);
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.