<input id="slider-one" type="text"
data-provide="slider"
data-slider-min="0"
data-slider-max="100"
data-slider-tooltip="show" />

<br>
<br>

<input id="slider-two" type="text"
data-provide="slider"
data-slider-ticks="[1, 2, 3, 4, 5]"
data-slider-ticks-labels='["1", "2", "3", "4", "5"]'
data-slider-min="1"
data-slider-max="5"
data-slider-step="1"
data-slider-value="3"
data-slider-tooltip="show" />

<h2>Example of a slider in a form</h2>
<form class="form-horizontal" role="form">
  <div class="form-group">
    <label for="size" class="col-sm-2 control-label">Size</label>
    <div class="col-sm-10">
      <input id="slider" type="text"
      data-provide="slider"
      data-slider-ticks="[1, 2, 3, 4, 5]"
      data-slider-ticks-labels='["1", "2", "3", "4", "5"]'
      data-slider-min="1"
      data-slider-max="5"
      data-slider-step="1"
      data-slider-value="3"
      data-slider-tooltip="show" />
    </div>
  </div>
  <div class="form-group">
    <label for="name" class="col-sm-2 control-label">Name</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="name">
    </div>
  </div>

  <div class="form-group">
    <label for="size" class="col-sm-2 control-label">Size</label>
    <div class="col-sm-10">
      <div class="slider-pf">
        <b>0</b>
        <input id="size" type="text"
        data-provide="slider"
        data-slider-min="0"
        data-slider-max="100"
        data-slider-tooltip="show" />
        <b>100</b>
        <input type="text" size="3" class="slider-input-pf">
        <span>GB</span>
      </div>
    </div>
  </div>

  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-default">Sign in</button>
    </div>
  </div>
</form>

<br>
<br>

<div class="slider-pf">
  <b>0</b>
  <input id="slider-pf" type="text"
  data-provide="slider"
  data-slider-min="0"
  data-slider-max="100"
  data-slider-tooltip="show" />
  <b>100</b>
  <input type="text" size="3" class="slider-input-pf">
  <span>GB</span>
</div>

<br>
<br>

<div class="slider-pf">
  <b>0</b>
  <input id="with-stops" type="text"
  data-provide="slider"
  data-slider-min="0"
  data-slider-max="100"
  data-slider-tooltip="show" />
  <b>100</b>
  <input type="text" size="3" class="slider-input-pf">
  <span class="dropdown">
    <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
      GB
      <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
      <li><a href="#">GB</a></li>
      <li><a href="#">MB</a></li>
    </ul>
  </span>
</div>
<script>
  $(function () {
    $('.slider-input-pf').tooltip({ trigger: 'manual' })
      .on('keyup', function (e) {
        var $this = $(this);
        var sd = $this.siblings('[data-provide=slider]').slider();
        if ($this.val().trim() !== '' && !$.isNumeric(this.value)) {
          this.value = sd.slider('getValue');
        }
      })
      .on('keypress blur', function (e) {
        if (e.which == 13 || e.type === 'blur') {
          e.preventDefault();
          var $this = $(this);
          var sd = $this.siblings('[data-provide=slider]').slider();
          var max = sd.slider('getAttribute', 'max');
          var min = sd.slider('getAttribute', 'min');
          if (!$.isNumeric(this.value) || (this.value > max || this.value < min)) {
            var warningInfo = $.isNumeric(this.value) ? 'Valid value should be between ' + min
              + ' and ' + max : 'Valid value should be number';
            $this.attr('data-original-title', warningInfo).tooltip('show').addClass('warning');
            this.value = sd.slider('getValue');
            setTimeout(function(){ $this.tooltip('hide'); }, 3000);
          } else {
            if ($this.is('.warning')) {
              $this.tooltip('hide');
            }
            this.value = $this.val().trim();
            sd.slider('setValue', this.value);
          }
        }
      })
      .siblings('[data-provide=slider]').each(function () {
        $(this).siblings('.slider-input-pf').val(this.value);
        $(this).slider().on('slide', function (e) {
          $(e.target).siblings('.slider-input-pf').val(e.value);
        });
      });
  });
</script>
