1

When you hold the up or down arrow on the input, even though its disabled, the input value stil changes. How do I fix this 'exploit' wothout deleting the arrows all together. Only on Firefox

Try it: Press the up arrow. After 5 seconds the input will disable, but you are still able to change the value.

Edit: The input is disabled such that When you click it to edit, it is disabled, but if you hold the arrow keys before it is disabled, the input will still change.

Why is this a duplicate question?

setTimeout ( function() {
var number = document.getElementById('number').disabled = true }, 5000)
<input type="number" id="number">

2 Answers2

1

Here is a basic answer, where you just put a hidden input in it, If you wanna escape all those jquery stuff etc.. This is a basic solution. Hope this helps you out <3

setTimeout ( function() {
document.getElementById('number').style.display = "none"; 
var result = document.getElementById('number').value;
document.getElementById('number1').value = result;
document.getElementById('number1').style.display = "block";     
document.getElementById('number1').disabled = true;
}, 5000)
<input type="number" id="number">
<input type="number" id="number1" hidden>
Maybe
  • 189
  • 11
  • This should not be the real answer. – Hemal Feb 02 '17 at 13:41
  • You are showing hidden element that is totally different from the element in question. – Hemal Feb 02 '17 at 13:41
  • This result works. On your post I get a simple alert for what? and even while this unnecessary alert is showing, you are able to incrase the amount of your input. – Maybe Feb 02 '17 at 13:47
  • You can remove alert. It just for debugging purpose. What I want to say is the element itself should be disable, not hidden, and then show other element. – Hemal Feb 02 '17 at 13:49
-1

If you're using jQuery (see tags), consider use .attr():

$("#number").attr('disabled','disabled');

Should work fine in Firefox >= v.50

Ref: http://caniuse.com/#feat=fieldset-disabled

Luiz Gonçalves
  • 549
  • 3
  • 11