Search code examples
javascriptjqueryrangeslider

Disable certain range in rangeslider.js


I am using rangeslider.js and I am trying to disable the slider to slide below 20

<input type="range" class="range-slider" value="30" min="0" max="100" from="0" step="1">

I am using start attribute to make that work but it doesn't work that way.

here is the fiddle https://jsfiddle.net/moviecrew/awejnkof/16/


Solution

  • if you set min attribute to 20 then it will create range slider value start from 20 or if you need value must start from 0 to 100 and prevent below 20 then you can try below solution

    $('input[type="range"]').rangeslider({
      polyfill: false,
      onSlide: function(position, value) {
        if(value < 20){
        $('input[type="range"]').val(20);
        $('input[type="range"]').rangeslider('update', true);
        }
      }
    });