I have a textbox which accepts numeric value.This is handled using javascript. I'd like to disable copy, paste and right click functionalities for the text box. Any help would be appreciated.
@Html.TextBoxFor(model => model.Days, new { @class = "input_box", @id = "txtDays", @onkeydown = "javascript:NumberOnly(this,event)"})
You can do it by using oncopy
and onpaste
event:
@Html.TextBoxFor(model => model.Days,
new {
@class = "input_box",
id = "txtDays",
oncopy="return false",
onpaste="return false"
}
)
You may want to visit this article which explains couple of ways to do it.
Following code might help you out.
$('#txtDays').bind("cut copy paste",function(e) {
e.preventDefault();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With