I have written below lines of code for blocking users to enter some values in textbox:
$(".block-keypress").keypress(function(e){
return false;
});
It is working fine but backspace is not blocked.
I have written below lines of code for blocking users to enter some values in textbox:
$(".block-keypress").keypress(function(e){
return false;
});
It is working fine but backspace is not blocked.
try with new code
use keydown
instead of keypress
$(".block-keypress").keydown(function(e) {
return false;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" class="block-keypress" value="test">