ng-maxlength $错误消息未显示

时间:2015-04-22 17:21:33

标签: html css angularjs validation

使用 ng-maxlength =&#34; 80&#34;在<input>字段中。

预期:

<span class="select2-container text-error resize" ng-show="myForm.sampleName.$error.maxlength">This can't be longer than 80 characters.</span>
如果<input>字段超过80个字符,则

显示

但是,错误消息未显示。 输入字段只有红色边框。没别了。

以下是我表单的一部分:

 <form name="myForm" class="form-horizontal" ng-show = "isFormActive()" novalidate>
    <div class="control-group">
              <label class="control-label buffer-right"><h5>Name:</h5></label>

              <div class="input-prepend buffer-left">
                <span class="add-on"><i class="icon-pencil"></i></span>
                <input type="text" name="sampleName" ng-model="person.name" ng-minlength="1" ng-maxlength="80" placeholder="Enter your comments here" required /></br>
                <span class="select2-container text-error resize" ng-show="myForm.sampleName.$error.maxlength">
                  This can't be longer than 80 characters.</span>
              </div>
    </div>
</form>

0 个答案:

没有答案