'How to save texts from text box to a variable and showing the variable to append
I'm new to coding and I was wondering how to correct the following code.
Basically, I want to save the user's scanned input to a variable and display it as a prepend. Also If possible being able to scan multiple scans while it just adds it to another variable so I can export the variables. Something like this when its exported as a .txt file
testscan1
tesstscan2
ABCDEF
var string = "";
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 < 8) {
$("#scanInput").val('');
} else {
$("body").append()
}
timeout = false
}
let timeout = false
$("#scanInput").keypress(function(e) {
if (performance.now() - lastInput > 50) {
$("#scanInput").val('')
}
lastInput = performance.now();
if (!timeout) {
timeout = setTimeout(checkValidity, 200)
}
});
<form autocomplete="off" onsubmit="return false">
<br>
<input type="text" name="serial" placeholder="Please scan laptop Barcode" id="scanInput" />
</form>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
