md-maxlength和ng-pattern

时间:2017-11-21 09:36:52

标签: javascript angularjs

我正在使用角度js 1.x(角度材质)

<div flex="100" flex-gt-sm="50">
<md-input-container class="md-block">
    <label>Quantity</label>
    <input type="text" ng-pattern="/^[0-9]+$/" name="qty" ng-model="SportEquipments.qty" md-maxlength="20" maxlength="20" required/>
    <div ng-messages="nSportEquipmentForm.qty.$error">
        <div ng-message="required">Quantity is required. </div>
        <div ng-message="pattern">Only Numbers are Allowed.</div>
    </div>
</md-input-container>
</div>

我保存数据后放pattern="/^[0-9]+$/"就好了。当我填充数据时,它会红色字段。当我输入并更改值时,验证完成..当我删除md-maxlength="20"时,行为正常

0 个答案:

没有答案