admin管理员组文章数量:1323005
Currently trying to use a standard datepicker but bine it with an input mask to make it easier to enter the date by hand if the user needs to.
See Plunk
The problem at the moment is that when I add the mask one of two things happens, either hand typing the date into the field doesn't work (meaning as soon as I finish it deletes the value from the field) OR it succeeds in updating the model value but when I open the datepicker
it is set to the year 1500
.
The plunk has both a masked and unmasked version of the input.
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;
};
});
Currently trying to use a standard datepicker but bine it with an input mask to make it easier to enter the date by hand if the user needs to.
See Plunk
The problem at the moment is that when I add the mask one of two things happens, either hand typing the date into the field doesn't work (meaning as soon as I finish it deletes the value from the field) OR it succeeds in updating the model value but when I open the datepicker
it is set to the year 1500
.
The plunk has both a masked and unmasked version of the input.
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;
};
});
Share
Improve this question
asked May 12, 2015 at 17:53
diplosaurusdiplosaurus
2,5885 gold badges29 silver badges56 bronze badges
2 Answers
Reset to default 1datetimepicker master is the solution
jQuery('#datetimepicker_mask').datetimepicker({
timepicker:false,
mask:true, // '9999/19/39 29:59' - digit is the maximum possible for a cell
});
http://xdsoft/jqplugins/datetimepicker/
You don't need mask as the api will do it for you
<input class='form-control' data-provide='datepicker' data-date-format='yyyy-mm-dd'>
本文标签: javascriptUIBootstrap datepicker with input maskStack Overflow
版权声明:本文标题:javascript - UI-Bootstrap datepicker with input mask - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742115372a2421442.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论