/** * name: public.Echart * date: 2017-5-24 */ function isEmpty(value) { return angular.isUndefined(value) || value === '' || value === null || value !== value; } define(['publicMax'], function () { angular.module('public.Max', []).directive('ngMax', function($http, $window) { return { restrict: 'A', require: 'ngModel', link: function (scope, elem, attr, ctrl) { scope.$watch(attr.ngMax, function () { ctrl.$setViewValue(ctrl.$viewValue); }); var maxValidator = function (value) { var max = scope.$eval(attr.ngMax) || Infinity; if (!isEmpty(value) && value >= max) { ctrl.$setValidity('ngMax', false); return undefined; } else { ctrl.$setValidity('ngMax', true); return value; } }; ctrl.$parsers.push(maxValidator); ctrl.$formatters.push(maxValidator); } }; }) });
/** * name: public.Echart * date: 2017-5-24 */ function isEmpty(value) { return angular.isUndefined(value) || value === '' || value === null || value !== value; } define(['publicMin'], function () { angular.module('public.Min', []).directive('ngMin', function($http, $window) { return { restrict: 'A', require: 'ngModel', link: function (scope, elem, attr, ctrl) { scope.$watch(attr.ngMin, function () { ctrl.$setViewValue(ctrl.$viewValue); }); var minValidator = function (value) { var min = scope.$eval(attr.ngMin) || 0; if (!isEmpty(value) && value <= min) { ctrl.$setValidity('ngMin', false); return undefined; } else { ctrl.$setValidity('ngMin', true); return value; } }; ctrl.$parsers.push(minValidator); ctrl.$formatters.push(minValidator); } }; }) });
<div class='col-xs-6'>
<div class="form-group" ng-class="{true:'red',false:''}[myForm3.everymanLow_edit.$dirty && myForm3.everymanLow_edit.$invalid &&!everymanLow_edit]">
<label class="col-xs-4 control-label"><span class="red">*</span>普通柜员低限</label>
<div class="col-xs-8">
<input class="form-control" placeholder="请输入数字" id="everymanLow_edit" name="everymanLow_edit" ng-model="everymanLow_edit" type="text" value="" ng-minlength="1" ng-maxlength="20" minlength="1" maxlength="20" ng-pattern="/^\d+(\.\d+)?$/" required>
<span class="red show_Notes" ng-show="myForm3.everymanLow_edit.$dirty && myForm3.everymanLow_edit.$invalid &&!everymanLow_edit" >请输入普通柜员低限!</span>
</div>
</div>
</div>
<div class='col-xs-6'>
<div class="form-group" ng-class="{true:'red',false:''}[myForm3.everymanHigh_edit.$dirty && myForm3.everymanHigh_edit.$invalid &&!everymanHigh_edit && myForm3.everymanHigh_edit.$error.ngMin]">
<label class="col-xs-4 control-label"><span class="red">*</span>普通柜员高限</label>
<div class="col-xs-8">
<input class="form-control" ng-min="everymanLow_edit" ng-max="directorHigh_edit" placeholder="请输入数字" id="everymanHigh_edit" name="everymanHigh_edit" ng-model="everymanHigh_edit" type="text" value="" ng-minlength="1" ng-maxlength="20" minlength="1" maxlength="20" ng-pattern="/^\d+(\.\d+)?$/" required>
<span class="red show_Notes" ng-show="myForm3.everymanHigh_edit.$dirty && myForm3.everymanHigh_edit.$invalid &&!everymanHigh_edit && myForm3.everymanHigh_edit.$error.ngMin" >请输入普通柜员高限!</span>
</div>
</div>
</div>
<div class='col-xs-6'>
<div class="form-group" ng-class="{true:'red',false:''}[myForm3.directorLow_edit.$dirty && myForm3.directorLow_edit.$invalid &&!directorLow_edit && myForm3.directorLow_edit.$error.ngMin]">
<label class="col-xs-4 control-label"><span class="red">*</span>审批主管低限</label>
<div class="col-xs-8">
<input class="form-control" ng-min="everymanLow_edit" ng-max="directorHigh_edit" placeholder="请输入数字" id="directorLow_edit" name="directorLow_edit" ng-model="directorLow_edit" type="text" value="" ng-minlength="1" ng-maxlength="20" minlength="1" maxlength="20" ng-pattern="/^\d+(\.\d+)?$/" required>
<span class="red show_Notes" ng-show="myForm3.directorLow_edit.$dirty && myForm3.directorLow_edit.$invalid &&!directorLow_edit && myForm3.directorLow_edit.$error.ngMin" >请输入审批主管低限!</span>
</div>
</div>
</div>
<div class='col-xs-6'>
<div class="form-group" ng-class="{true:'red',false:''}[myForm3.directorHigh_edit.$dirty && myForm3.directorHigh_add.$invalid &&!directorHigh_edit && myForm3.directorHigh_edit.$error.ngMin]">
<label class="col-xs-4 control-label"><span class="red">*</span>审批主管高限</label>
<div class="col-xs-8">
<input class="form-control" ng-min="directorLow_edit" ng-max="sectionchiefHigh_edit" placeholder="请输入数字" id="directorHigh_edit" name="directorHigh_edit" ng-model="directorHigh_edit" type="text" value="" ng-minlength="1" ng-maxlength="20" minlength="1" maxlength="20" ng-pattern="/^\d+(\.\d+)?$/" required>
<span class="red show_Notes" ng-show="myForm3.directorHigh_edit.$dirty && myForm3.directorHigh_edit.$invalid &&!directorHigh_edit && myForm3.directorHigh_edit.$error.ngMin" >请输入审批主管高限!</span>
</div>
</div>
</div>
<div class='col-xs-6'>
<div class="form-group" ng-class="{true:'red',false:''}[myForm3.sectionchiefLow_edit.$dirty && myForm3.sectionchiefLow_edit.$invalid &&!sectionchiefLow_edit && myForm3.sectionchiefLow_edit.$error.ngMin]">
<label class="col-xs-4 control-label"><span class="red">*</span>审批处长低限</label>
<div class="col-xs-8">
<input class="form-control" ng-min="directorLow_edit" ng-max="sectionchiefHigh_edit" placeholder="请输入数字" id="sectionchiefLow_edit" name="sectionchiefLow_edit" ng-model="sectionchiefLow_edit" type="text" value="" ng-minlength="1" ng-maxlength="20" minlength="1" maxlength="20" ng-pattern="/^\d+(\.\d+)?$/" required>
<span class="red show_Notes" ng-show="myForm3.sectionchiefLow_edit.$dirty && myForm3.sectionchiefLow_edit.$invalid &&!sectionchiefLow_edit && myForm3.sectionchiefLow_edit.$error.ngMin" >请输入审批处长低限!</span>
</div>
</div>
</div>
<div class='col-xs-6'>
<div class="form-group" ng-class="{true:'red',false:''}[myForm3.sectionchiefHigh_edit.$dirty && myForm3.sectionchiefHigh_edit.$invalid &&!sectionchiefHigh_edit && myForm3.sectionchiefHigh_edit.$error.ngMin]">
<label class="col-xs-4 control-label"><span class="red">*</span>审批处长高限</label>
<div class="col-xs-8">
<input class="form-control" ng-min="sectionchiefLow_edit" ng-max="topmanagerHigh_edit" placeholder="请输入数字" id="sectionchiefHigh_edit" name="sectionchiefHigh_edit" ng-model="sectionchiefHigh_edit" type="text" value="" ng-minlength="1" ng-maxlength="20" minlength="1" maxlength="20" ng-pattern="/^\d+(\.\d+)?$/" required>
<span class="red show_Notes" ng-show="myForm3.sectionchiefHigh_edit.$dirty && myForm3.sectionchiefHigh_edit.$invalid &&!sectionchiefHigh_edit && myForm3.sectionchiefHigh_edit.$error.ngMin" >请输入审批处长高限!</span>
</div>
</div>
</div>
<div class='col-xs-6'>
<div class="form-group" ng-class="{true:'red',false:''}[myForm3.topmanagerLow_edit.$dirty && myForm3.topmanagerLow_edit.$invalid &&!topmanagerLow_edit && myForm3.topmanagerLow_edit.$error.ngMin]">
<label class="col-xs-4 control-label"><span class="red">*</span>审批总经理低限</label>
<div class="col-xs-8">
<input class="form-control" ng-min="sectionchiefLow_edit" ng-max="topmanagerHigh_edit" placeholder="请输入数字" id="topmanagerLow_edit" name="topmanagerLow_edit" ng-model="topmanagerLow_edit" type="text" value="" ng-minlength="1" ng-maxlength="20" minlength="1" maxlength="20" ng-pattern="/^\d+(\.\d+)?$/" required>
<span class="red show_Notes" ng-show="myForm3.topmanagerLow_edit.$dirty && myForm3.topmanagerLow_add.$invalid &&!topmanagerLow_edit && myForm3.topmanagerLow_edit.$error.ngMin" >请输入审批总经理低限!</span>
</div>
</div>
</div>
<div class='col-xs-6'>
<div class="form-group" ng-class="{true:'red',false:''}[myForm3.topmanagerHigh_edit.$dirty && myForm3.topmanagerHigh_edit.$invalid &&!topmanagerHigh_edit && myForm3.topmanagerHigh_edit.$error.ngMin]">
<label class="col-xs-4 control-label"><span class="red">*</span>审批总经理高限</label>
<div class="col-xs-8">
<input class="form-control" ng-min="topmanagerLow_edit" placeholder="请输入数字" id="topmanagerHigh_edit" name="topmanagerHigh_edit" ng-model="topmanagerHigh_edit" type="text" value="" ng-minlength="1" ng-maxlength="20" minlength="1" maxlength="20" ng-pattern="/^\d+(\.\d+)?$/" required>
<span class="red show_Notes" ng-show="myForm3.topmanagerHigh_edit.$dirty && myForm3.topmanagerHigh_edit.$invalid &&!topmanagerHigh_edit && myForm3.topmanagerHigh_edit.$error.ngMin" >请输入审批总经理高限!</span>
</div>
</div>
</div>
转载于:https://blog.51cto.com/zifeng5966/1950693