0

I am trying to validate textAngular fileds, I need to add required, max and min characters and border color on red/green on textAngular... I have for each loop and inide textAngulars...

Here is my code:

 <form ng-submit="addReply(x)" class="dd animated slideInDown" novalidate>
            <div class="form-group">
                <text-angular ng-minlength=10 ng-maxlength=600 required ta-text-editor-class="form-control myform1-height" ta-html-editor-class="form-control myform1-height" ta-toolbar="[['bold','italics']]" style="min-height: 100px; color:red;" ng-model="form.reply[x.pivot.comment_id]"></text-angular>

                <span  ng-show="form.reply[x.pivot.comment_id].$dirty && form.reply[x.pivot.comment_id].$invalid"></span>
                <span ng-show="form.reply[x.pivot.comment_id].$error.min || form.reply[x.pivot.comment_id].$error.max">
      The value must be in range 0 to 10!</span>
                <span ng-show="form.reply[x.pivot.comment_id].$error.required">Email is required.</span>
            </div>
            <div class="form-group">
                <addreply></addreply>
            </div>
        </form>

My code don't work I don't know why...

Vladimir Djukic
  • 2,042
  • 7
  • 29
  • 60
  • What part exactly isn't working? Is any of the validation working? I think the ng-min/maxlength should have quotations around their values. ng-minlength="10" ng-maxlength="600" which could be causing the problem. – user3407039 Sep 20 '15 at 20:10
  • Not wotking: color on textarea, not show error messages... – Vladimir Djukic Sep 20 '15 at 21:23

2 Answers2

0

According to AngularJS documentation, your form and inputs should have names. Then you should set validation ng-show's to form_name.input_name.$error and so on, like here

asm0dey
  • 2,841
  • 2
  • 20
  • 33
0

this one is a small example based on your question for

 validating the required field

http://plnkr.co/edit/6PTNg3atPHAjL0XFtvWj?p=info

Jenson Raby
  • 769
  • 2
  • 6
  • 26