2
是否可以手动将字段有效性设置为无效bootstrap validator?在自举验证器中手动设置有效性
我采用了棱角分明的JS在我的项目,要使用日期范围验证。
“最大最新的”属性适用,除非我手动输入的日期很好,这就是为什么我要重新验证控制器领域和手动设置字段有效性。
HTML:
<div class="form-group inputGroupContainer" ng-controller="DatepickerCtrl">
<label for="date">Date of Birth</label>
<p class="input-group">
<input type="text" name="date1" placeholder="DD/MM/YYYY" class="form-control" ui-date="{dateFormat: 'dd/MM/yyyy'}" ui-date-format="dd/MM/yyyy" datepicker-popup="{{format}}" ng-model="user.Personal.BirthDate" max-date="currentDate" is-open="opened" close-text="Close" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</p>
</div>
angularjs控制器:
$scope.$watch('user.Personal.BirthDate', function (newValue, oldValue) {
if (newValue !== oldValue) {
if ($scope.user.Personal.BirthDate)
if ($scope.user.Personal.BirthDate.getTime() > new Date().getTime()) {
//set validity for "date1" to invalid
}
$($('#editPersonalForm')).bootstrapValidator('revalidateField', 'date1');
}
});
的情况下是非常有用的提示。 – 2017-08-15 11:43:23