I have an input field which will be updated every x seconds:
<input type="number" name="METER" id="METER.NUM" min="0" max="500" step="0.10" oninput="setMeter(currentValue);" >
Now, I want to check if the input field has focus (user clicked into the field).
If the field has focus:
- I will stop updating the field and the user can put some value into the field
- Then the value should be passed to a function
This is the javascript code:
if (document.getElementById(array[0]).name == "METER") {
// check if the input field has focus
// stop updating
}
What's wrong with my approch/code? I think one problem is, that the function call by oninput doesn't work. But it works by onClick.
$(my_element_id_here).is(":focus")