Sorry, Javasvript noob here…
In the code below, why does the focus not go (back) to the text field “id1” when I enter an illegal value (= anything other than 1 to 9) in that field? The problem seems to be FF-specific. It works as I’d expect in Chromium. Any ideas on how to get it to work in FF?
<!DOCTYPE html>
<html>
<body>
<input type="text" id="id1">
<input type="text" id="id2">
<script>
document.getElementById("id1").addEventListener("change", function() { single_digit("id1"); } );
function single_digit(item)
{
f = document.getElementById(item);
if (!/^[1-9]$/.test(f.value)) {
f.value = '';
f.focus();
}
}
</script>
</body>
</html>
Thanks for any insights/help/tips/words of comfort you may be able to provide!
EDIT:
Found a solution: https://coderanch.com/t/464594/languages/focus-working-firefox