html - How to create two inputs for the same field with responsive design? -


i'm trying create responsive design form number input in form-group using thymeleaf , bootstrap.
goal make such input slider type on mobile devices, , text type on medium devices , bigger:

enter image description here

for reason i'm using 2 different divs same field residents different classes show , hide content depending on device screen width (e.g. hidden-xs, hidden-sm, hidden-md, hidden-lg).

<div class="form-group required hidden-sm hidden-md hidden-lg">     <label for="range_02" class="col-sm-2 control-label">residents:</label>     <input id="range_02" type="text" class="form-control" value="1" th:field="*{residents}"/> </div>  <div class="form-group required hidden-xs">     <label for="residents" class="col-sm-2 control-label">residents:</label>     <input id="residents" type="text" class="form-control" th:field="*{residents}" placeholder="4"/> </div> 

the input fields visibility okay, changes while change window width. seems couldn't use 2 inputs same field @ same time - value passing through first input slider.

i tried pass 2 inputs same div , use same visibility options text , slider inputs. result same.

how set input not hidden inactive when 1 shown?

as @jasc. suggested binded slider input text input fields js function:

$(function () {     var $range = $("#range_02"),         $input = $("#residents"),         instance,         min = 1,         max = 10;      $range.ionrangeslider({         type: "single",         min: min,         max: max,         onstart: function (data) {             $input.prop("value", data.from);         },         onchange: function (data) {             $input.prop("value", data.from);         }     });      instance = $range.data("ionrangeslider");      $input.on("change keyup", function () {         var val = $(this).prop("value");          if (val < min) {             val = min;         } else if (val > max) {             val = max;         }          instance.update({             from: val         });     }); }); 

the thing have need to make construction works put text input above slider input on form.


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -