Touch & Desktop Layout
Use the calendar for both mobile and desktop or set it up responsively.
The main difference between the two rendering modes is how the picker is laid out. Set the touchUi option to false and the component shows up suitable for larger screens and pointer interaction while setting it to true renders it suitable for touch screens.
Use the date picker on an existing form field, custom input or use it on Mobiscroll form fields. You can also embed it directly into your page. When linked to an input, the component will be shown on focus or when someone clicks on the field. Alternatively, you can leave the input editable and show the component only on a button click.
Demo
html<input id="input-picker" />
jsmobiscroll.datepicker('#input-picker', {
controls: ['calendar'],
touchUi:
});
html<label>
<input id="mobi-picker" mbsc-input />
</label>
jsmobiscroll.datepicker('#mobi-picker', {
controls: ['calendar'],
touchUi:
});
html<div id="inline-picker"></div>
jsmobiscroll.datepicker('#inline-picker', {
controls: ['calendar'],
display: 'inline',
touchUi:
}); mobiscroll.setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
mobiscroll.datepicker('#demo-mobile-picker-input', {
controls: ['calendar'],
});
var instance = mobiscroll.datepicker('#demo-mobile-picker-button', {
controls: ['calendar'],
showOnClick: false,
showOnFocus: false,
});
instance.setVal(new Date(), true);
mobiscroll.datepicker('#demo-mobile-picker-mobiscroll', {
controls: ['calendar'],
});
mobiscroll.datepicker('#demo-mobile-picker-inline', {
controls: ['calendar'],
display: 'inline',
});
document.getElementById('show-mobile-date-picker').addEventListener('click', function () {
instance.open();
return false;
});
<div class="mbsc-grid">
<div class="mbsc-form-group">
<div class="mbsc-row">
<div class="mbsc-col-12">
<div class="mbsc-txt-muted md-mobile-picker-header">Use the picker with any inputs & show on focus/click</div>
<input id="demo-mobile-picker-input" class="md-mobile-picker-input" placeholder="Please Select..." />
</div>
</div>
</div>
<div class="mbsc-form-group">
<div class="mbsc-row">
<div class="mbsc-col-12 mbsc-txt-muted md-mobile-picker-header">Disable <code>onClick/onFocus</code> and only show on button</div>
<div class="mbsc-col-8">
<input id="demo-mobile-picker-button" class="md-mobile-picker-input" />
</div>
<div class="mbsc-col-4">
<button mbsc-button data-variant="outline" data-color="primary" id="show-mobile-date-picker" class="md-mobile-picker-button">Show picker</button>
</div>
</div>
</div>
<div class=" mbsc-form-group">
<div class="mbsc-row">
<div class="mbsc-col-12">
<div class="mbsc-txt-muted md-mobile-picker-header">Use the picker with a Mobiscroll input</div>
<label class="md-mobile-picker-box-label">
<input id="demo-mobile-picker-mobiscroll" mbsc-input data-label-style="stacked" data-input-style="box" placeholder="Please Select..." />
</label>
</div>
</div>
</div>
<div class="mbsc-txt-muted md-mobile-picker-header">Use the picker inline in any page</div>
</div>
<div class="md-mobile-picker-inline">
<div id="demo-mobile-picker-inline"></div>
</div>
.md-mobile-picker-header {
font-size: 14px;
}
input.md-mobile-picker-input {
color: initial;
width: 100%;
padding: 10px;
margin: 6px 0 12px 0;
border: 1px solid #ccc;
border-radius: 0;
font-family: arial, verdana, sans-serif;
font-size: 14px;
box-sizing: border-box;
-webkit-appearance: none;
}
.md-mobile-picker-button.mbsc-button {
font-size: 13px;
padding: 0 15px;
line-height: 36px;
float: right;
margin: 6px 0;
width: 100%;
}
.mbsc-col-no-padding {
padding-left: 0;
}
.md-mobile-picker-box-label.mbsc-textfield-wrapper-box,
.md-mobile-picker-box-label .mbsc-textfield-wrapper-box,
.md-mobile-picker-inline {
margin: 6px 0 12px 0;
}