angular-validation 검사 숫자

2596 단어 angularjs
<input type="number" min="0" max="100" maxlength="5" class="number" ng-model="formData.age" validator="number,required,range" ng-class="{'has-error':orderForm.age.$invalid}" ng-blur="showError(true)" 
 ng-mouseenter="isShowTipsA=true" ng-mouseleave="isShowTipsA=false" is-show-tips="isShowTipsA" 
 range-error-message=" 0~100 " required-error-message=" ">
/**
     * Range Validation
     */
    $validationProvider.setExpression({
        range: function(value, scope, element, attrs) {
          if (value >= parseInt(attrs.min) && value <= parseInt(attrs.max)) {
            return value;
          }
        }
      }).setDefaultMsg({
        range: {
          error: 'Number should between 0 ~ 100',
          success: 'good'
        }
      });

좋은 웹페이지 즐겨찾기