0

Hello I have an input range with values 0-380 and I want to disable some value, like ID 30. So when I select 29 and press the right arrow, it must be change to 31.

1 Answer 1

0

Just check if the slider.value is on a certain number, and if it is, do something to avoid the number. Here's a simple way I thought to fix this, but this is by no means the best way.

var slider = document.getElementById("myRange");
var output = document.getElementById("demo");
output.innerHTML = slider.value;

function removeNum(num) {
    if (slider.value == num-1) {slider.value++}
  else if (slider.value == num+1) {slider.value--}
}

slider.oninput = function() {
  output.innerHTML = this.value;
  removeNum(10) //Doesn't allow slider to go to number 10
}
 <input type="range" min="1" max="100" value="50" class="slider" id="myRange">
 <p>Value: <span id="demo"></span></p>
 

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the quick answer, its almost working, but now the value stuck in 9-11. (with using the keypad arrows)
Perhaps this article can help you? stackoverflow.com/questions/23014375/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.