i am trying to intergrate javascript with textbox, but it is not working
i want that textbox do not take input from keyboard or (Copy/Paste), just allowed from barcode scanner device to take input
<script type="text/javascript">
let inputStart, inputStop;
$("#scanInput")[0].onpaste = e => e.preventDefault();
// handle a key value being entered by either keyboard or scanner
var lastInput
let checkValidity = () => {
if ($("#scanInput").val().length < 10) {
$("#scanInput").val('')
} else {
$("body").append($('<div style="background:green;padding: 5px 12px;margin-bottom:10px;" id="msg">ok</div>'))
}
timeout = false
}
let timeout = false
$("#scanInput").keypress(function (e) {
if (performance.now() - lastInput > 1000) {
$("#scanInput").val('')
}
lastInput = performance.now();
if (!timeout) {
timeout = setTimeout(checkValidity, 200)
}
});
</script>
<asp:TextBox ID="scanInput" AutoPostBack="true" runat="server" Placeholder="Input Bale No" autocomplete="off" Height="30px" Width="208px" style="margin-left: 0px"></asp:TextBox>