How do i restrict user to enter any data from Keyboard to Text-box. Actually my requirement is that, this particular textbox is being used for only scanning purpose. Hence, only scanned data will be entered to this textbox and want to restrict any manually entered data from keyboard.
How do i restrict user to enter any data from Keyboard to Text-box. Actually my requirement is that, this particular textbox is being used for only scanning purpose. Hence, only scanned data will be entered to this textbox and want to restrict any manually entered data from keyboard.
Share Improve this question asked Aug 9, 2013 at 5:33 user2450398user2450398 1951 gold badge7 silver badges17 bronze badges 1- 1 Can we see some code of what you are doing? – rink.attendant.6 Commented Aug 9, 2013 at 5:39
4 Answers
Reset to default 2Just disable the textbox and get the value from the backend will solve the issue.
SAMPLE FIDDLE
I dont think there is any need of javascript here.
Just use readonly in you html.
<input value="somevalue" name="meow" readonly>
Thats it.No fancy javascript needed.
Try this
$(function(){
$('input[type=text]').bind('keyup keydown keypress', function (evt) {
return false;
});
});
Demo
If you want to fill data from backend then you can permanently disable for that you just need to add in textbox html readonly and then fill value by
document.getElementById("yourtextbox_id").value="your_scanned_value";