0

Is it possible to create an intput of type range and disable some values from it ? Like having a slider from 0 to 100 and disable 0 and 100 because I want to select 0 and 100 only by using checkbox. So the user can slide from 1 to 99 and need to use the checkboxes to get 0 or 100.

<input type="range" min="0" max="100" id="priority-box"/>

2 Answers 2

1

jQuery UI has something built in specifically for that.

http://jqueryui.com/slider/#range

$(function() {
    $( "#slider-range" ).slider({
      range: true,
      min: 0,
      max: 500,
      values: [ 75, 300 ],
      slide: function( event, ui ) {
        $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
      }
    });
    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
      " - $" + $( "#slider-range" ).slider( "values", 1 ) );
  });

Hope this helps!

HTML5 Solution: (IE support for only 9+) http://jsfiddle.net/3aV5p/1/

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

5 Comments

So it's not possible in native javascript ? or basic jQuery ?
It should be, with a little more work. I'll see what I can come up with
Are you worried about support for previous than IE9 support?
Technicaly no, but I have solved the problem. My checkbox "max" set .val("100") and "min" set .val("0") in js. My slider goes from 1 to 99, and the value 100 and 0 are properly saved even if it's out of the scope. I mark you as the answer if it can help.
I added an HTML5 solution in the answer for you. The range slider is native to 5 but has little IE support.
1

Try use the slide event in jQuery UI with fixed maximum (http://jqueryui.com/demos/slider/#event-slide) ..

You set the minimum and maximum range in the script. This is from the source:

...

$(function() {
$( "#slider-range-max" ).slider({
range: "max",
min: 1,
max: 99,
value: 2,
slide: function( event, ui ) {
$( "#amount" ).val( ui.value );
}
});

...

Comments

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.