0

I have a textarea for which I have a validation pattern. I require the character count of this field even when the value entered is invalid/does not match the pattern.

What I see currently is that when the pattern match return invalid for the ng-model binded textarea, the length of textarea is zero.I need a way to get the count even in invalid case.

Code Follows :-

<textarea class="form-control" id="ccListId" name="ccListName" ng-model="ccList" my-maxlength=255 maxlength=255 ng-pattern="emailCCListRegex"></textarea>

Could anyone suggest a way here..thanks in advance

Prasad
  • 1,562
  • 5
  • 26
  • 40
  • 1
    Read this Post and http://stackoverflow.com/questions/20603107/angularjs-text-area-character-counter Fiddled :- http://jsfiddle.net/9DbYY/ – Prasad Feb 29 '16 at 18:01
  • That link doesn't address the issue here, which is that invalid input will have a zero-length model value. I believe you want to be checking the length of the `$viewValue` instead: https://docs.angularjs.org/api/ng/type/ngModel.NgModelController (unfortunately I'm rusty enough at this that I'm not able to give a full answer) – Daniel Beck Feb 29 '16 at 18:13

0 Answers0