Considering this HTML:
<input type="text" class="onlydelete" value="Nyedva Nyedva" />
The following jQuery function will only allow the Backspace key to be used in the input fields with class onlydelete.
$('.onlydelete').keypress(function (e) {
return (e.which===8);
});
UPDATE:
I've found that you also need the Delete key. And I guess you would also like to allow the arrow keys to let the user move the caret. For these special keys, you can use keydown. The following snippet only allows Delete (46), Backspace (8), and arrow keys (37-40).
$('.onlydelete').keydown(function (e) {
return (e.which===46 || e.which===8 || (e.which>=37 && e.which<=40));
});
UPDATE 2:
The other good thing about adding a class is that you can easily style these special inputs with css. For example:
.onlydelete { background-color: #aaaaaa; }