我的角度形式验证不起作用

时间:2016-12-26 03:18:04

标签: javascript angularjs forms twitter-bootstrap

我使用带有角度的bootstrap,并且我禁用了bootstrap的验证,角度仍然不起作用。似乎我已经设定了一切。

我的代码喜欢以下内容,每个输入的验证都没有。

<form novalidate name="new_people" ng-if="is_editting_newpeople" class="form-horizontal" role="form" ng-submit="save_new_people()">    
    <div class="input-group">
        <div class="input-group-addon">True Name</div>
        <input class="form-control" name="realname" type="text" ng-model="editting_people.realname" autofocus required>
    </div>

    <div class="input-group">
        <div class="input-group-addon">Nickname</div>
        <input type="text" name="nickname" class="form-control" id="nickname" ng-model="editting_people.nickname" required>
    </div>
    <div class="input-group">
        <div class="input-group-addon">Mobilenumber</div>
        <input type="text" class="form-control" id="mobile" name="mobilenumber" ng-model="editting_people.mobilenumber" required ng-minlength=11>
    </div>
    <div class="input-group">
        <div class="input-group-btn">
            <button type="button" class="btn btn-default
                        dropdown-toggle" data-toggle="dropdown">{{ editting_people.idclass.name }}
                      <span class="caret"></span>
                    </button>
            <ul class="dropdown-menu">
                <li ng-repeat="id_class in IDCLASSES">
                    <a ng-click="set_id_class(id_class)">{{ id_class.name }}</a>
                </li>
            </ul>
        </div>
        <!-- /btn-group -->
        <input type="text" class="form-control" ng-model="editting_people.idnumber" required name="idnumber">
    </div>
    <!-- /input-group -->
    <br>
    <input class="btn btn-primary" type="submit" value="Submit" />
    <input class="btn btn-default" value="取消" type="button" ng-click="cancel_new_people()" />
</form>

1 个答案:

答案 0 :(得分:0)

输入不起作用是什么意思? 请发布相关控制器的代码,因为不清楚你在做什么验证。如果你有novalidate,你应该在角度控制器或HTML中组织验证,例如:

<div ng-show="editting_people.realname.length<4">
 Any error message here.
</div>