addclass angularjs

   <td><input ng-model="Data[31].percentage" ng-blur="Blur($event,Data[31].percentage)"></td>
                 <td><input ng-model="Data[35].percentage" ng-blur="Blur($event,Data[35].percentage)"></td>
                 <td><input ng-model="Data[39].percentage" ng-blur="Blur($event,Data[39].percentage)"></td>
                 <td><input ng-model="Data[43].percentage" ng-blur="Blur($event,Data[43].percentage)"></td>
                 <td><input ng-model="Data[47].percentage" ng-blur="Blur($event,Data[47].percentage)"></td>
                 <td><input ng-model="Data[51].percentage" ng-blur="Blur($event,Data[51].percentage)"></td>
                 <td><input ng-model="Data[55].percentage" ng-blur="Blur($event,Data[55].percentage)"></td>
                 <td><input ng-model="Data[59].percentage" ng-blur="Blur($event,Data[59].percentage)"></td>
 $scope.Blur=function(event,i){
      //(排除0,但包含100)
       var reg = new RegExp("^[1-9][0-9]?$|^100$");
       //var testNum = 101;
       if(!reg.test(i)) {
           //alert("请输入0-100的整数!");
           $scope.open('sm');
           $(event.target).addClass('error');
       }else{
           $(event.target).removeClass('error');
           $(event.target).addClass('success');
       }
   }

 

posted @ 2017-05-25 17:08  liucong2016  阅读(695)  评论(0编辑  收藏  举报