Wijmo 5 - Date and Time Input
by Joel Parks
HTML
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.latest/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.latest/controls/wijmo.input.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css">
<div class="container">
<br><br><br><br>
<div class="row">
<div class="col-7 float-right">
<div class="float-right">
<label>AutoComplete: </label> <div id="theAutoComplete" style="width: 235px"></div><br>
</div>
<div class="float-right">
<label>ComboBox: </label> <div id="theComboBox" style="width: 235px"></div><br>
</div>
<div class="float-right">
<label>Numbers: </label> <div id="theInputNumber" style="width: 235px"></div><br>
</div>
<div class="float-right">
<label>Currency: </label> <div id="theInputCurrency" style="width: 235px"></div><br>
</div>
<div class="float-right">
<label>Date:</label> <div id="theInputDate" style="width: 235px"></div><br>
</div>
<div class="float-right">
<label>DateTime:</label> <div id="theDateTime" style="width: 235px"></div><br>
</div>
<div class="float-right">
<label>Time:</label> <div id="theInputTime" style="width: 235px"></div>
</div>
</div>
<div class="col-5">
<div class="float-right">
<label>SSN: </label> <div id="ssnMask"></div><br>
</div>
<div class="float-right">
<label>Phone: </label> <div id="phoneMask"></div><br>
</div>
<div class="float-right" style="display: inline-block">
<label>List: </label><br><div id="listBox"></div>
</div>
</div>
</div>
</div>
CSS
.wj-calendar {
max-width: 300px;
}
.wj-control {
margin-bottom: 6px;
}
body {
margin-bottom: 24pt;
}
JavaScript
onload = function() {
// the date/time being edited
var theDate = new Date();
// create InputDate control
var inputDate = new wijmo.input.InputDate('#theInputDate', {
min: new Date(2014, 8, 1),
format: 'M/d/yyyy',
value: theDate
});
// create InputTime control
var inputTime = new wijmo.input.InputTime('#theInputTime', {
min: new Date(2014, 8, 1, 9, 0),
max: new Date(2014, 8, 1, 17, 0),
step: 15,
format: 'h:mm tt',
value: theDate
});
var autoComplete = new wijmo.input.AutoComplete('#theAutoComplete', {
itemsSource: getAutoData()
});
var comboBox = new wijmo.input.ComboBox('#theComboBox', {
itemsSource: getDirection(),
});
var numbers = new wijmo.input.InputNumber('#theInputNumber', {
step: 1,
value: 10
});
var currency = new wijmo.input.InputNumber('#theInputCurrency', {
step: 1,
format: 'c2',
value: 38
});
var dateTime = new wijmo.input.InputDateTime('#theDateTime');
var ssnMask = new wijmo.input.InputMask('#ssnMask', {
mask: '000-00-0000'
});
var phoneMask = new wijmo.input.InputMask('#phoneMask', {
mask: '(999) 000-0000'
});
var listBox = new wijmo.input.ListBox('#listBox', {
itemsSource: getContinents()
});
// create Calendar control
var calendar = new wijmo.input.Calendar('#theCalendar', {
min: new Date(2014, 8, 1),
value: theDate
});
calendar.valueChanged.addHandler(valueChanged);
function getAutoData() {
return ['US', 'China', 'Japan', 'France', 'Germany', 'UK'];
}
function getContinents() {
return ['Asia', 'Africa', 'North America', 'South America', 'Antarctica', 'Europe', 'Australia'];
}
function getDirection() {
return ['North', 'South', 'East', 'West'];
}
}