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();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.