I'm stumped on what is causing this issue. The input field is still displaying letters when it shouldn't be.
<script>
let value = "";
function isNumber(value) {
return !isNaN(value);
}
function handleInput(e) {
let oldValue = value;
let newValue = e.target.value;
console.log(oldValue, newValue, "isNumber", isNumber(newValue));
if (isNumber(newValue) && newValue.length < 17) {
value = newValue;
} else {
value = oldValue;
}
}
</script>
<div class="container">
<input
{value}
on:input|preventDefault={handleInput}
/>
</div>
Check out the REPL link for more details.