當前嘗試使用標準日期選擇器,但將其與輸入掩碼結合,以便用戶更容易手動輸入日期。帶輸入掩碼的UI-Bootstrap datepicker
目前最大的問題是,當我補充面具的發生兩種情況之一,無論是手動輸入的日期到現場不工作(只要我完成它刪除值含義從現場)或它成功地更新模型值,但當我打開datepicker
它設置爲年1500
。
該plunk具有輸入的蒙版和非蒙版版本。
HTML
<input type="text" class="form-control" datepicker-popup="MM/dd/yyyy" ng-model="dt" is-open="opened" min-date="'2010-01-02'" max-date="dt" ng-required="true" close-text="Close" show-weeks="false" show-button-bar="false" ui-mask="99/99/9999" />
<button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
JS
.controller('DatepickerDemoCtrl', function ($scope) {
$scope.dt = new Date();
$scope.open = function($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.opened = true;
};
});
有時,用戶想在日期選擇器中輸入文本框而不是使用鼠標。 – Blaise