I'm trying to create a responsive design form with number input in form-group
using Thymeleaf and Bootstrap.
My goal is to make such input that would be the slider type on mobile devices, and the text type on medium devices and bigger:
For that reason I'm using the two different divs for the same field residents
with different classes to show and hide content depending on the 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 is okay, it changes while I change my window width. However it seems I couldn't use 2 inputs for the same field at the same time - value is passing only through the first input which is slider.
I also tried to pass this two inputs to the same div and use the same visibility options for text and slider inputs. But the result is the same.
How to set another input not only hidden but inactive as well when the one is already shown?