[英]How to accept only date as input field value for bootstrap datepicker in angular
<form name="eventInformation" id="eventInformation"><label class="required"> Occurence Date </label>
<p class="input-group">
<input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="formData_EventDetails.eventOccurDate"
is-open="popup[0].opened" datepicker-options="dateOptions" close-text="Close" required/>
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open(0)"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</p>
<div class="col-sm-2 pull-right">
<button class="btn btn-block btn-primary ebtn"
ng-disabled="eventInformation.$invalid"
ng-click="submit()">Save</button>
</div>
</form>
$scope.format = 'yyyy/MM/dd';
$scope.dateOptions = {
formatYear : 'yy',
startingDay : 1
};
$scope.popup = [];
for (i = 0; i < 10; i++) {
$scope.popup[i] = {
opened : false
};
}
$scope.open = function(i) {
$scope.popup[i].opened = true;
};
我有一个bootstrap datepicker元素,我试图只接受日期作为输入,但是它接受各种输入,即字符串,数字等。我如何限制所以它仅将日期作为输入
由于它是输入文本框,因此您不能限制用户输入无效字符(默认行为)。
但是,当用户提供错误的日期时,您可以停止模型更新操作(为此,您需要在输入元素上设置以下属性)
ng-model-options="{allowInvalid: false}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.