0

I have used text-angular for getting input from user. The below code does not validate the input

    <div text-angular ng-pattern="/^[a-zA-Z0-9\-\s]+$/" name="description" ng-minlength="100" ta-min-text="100" required>
     </div>
  <p ng-show="jform.description.$invalid && !jform.description.$pristine && !jform.description.$error.pattern" class="help-block">Invalid input</p>

whereas ng-pattern works on

 <input type="text" ng-pattern="/^[a-zA-Z0-9\-\s]+$/" name="description">
  <p ng-show="jform.description.$invalid && !jform.description.$pristine && !jform.description.$error.pattern" class="help-block">Invalid input</p>

Does the text-angular has different attribute for ng-pattern?

Any help will be highly appreciated.

Chetan Gawai
  • 2,361
  • 1
  • 25
  • 36

1 Answers1

0

"ngPattern adds the pattern validator to ngModel" (https://docs.angularjs.org/api/ng/directive/ngPattern),
"The ngModel directive binds an input,select, textarea" (https://docs.angularjs.org/api/ng/directive/ngModel).

I think the problem is that you are trying to add a pattern validator to an element which is not input, select nor textarea. I think text-area directive creates an input element and binds it to ng-model found in its attributes, but doesn't bind ng-pattern.

Gerard
  • 196
  • 6