Reputation: 195
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.
Upvotes: 1
Views: 5490
Reputation: 3353
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";
Upvotes: 0
Reputation: 17757
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.
Upvotes: 2
Reputation: 2209
Just disable the textbox and get the value from the backend will solve the issue.
Upvotes: 2