1. 程式人生 > >AngularJs的自定義的正則校驗指令--程式碼共享

AngularJs的自定義的正則校驗指令--程式碼共享

1.對URL地址值的格式校驗

2.對純數字做校驗


3.使用方式

比如校驗http:

<span style="font-size:14px;"><input type="text" class="form-control" valid-http="{{值}}" name="xuexi"/>
<small class="error" ng-show="myForm.xuexi</span><span style="font-size:14px;">.$error.http">
    *資料格式不合法(如:http://xxx)
</small></span>
比如校驗數字:
<span style="font-size:14px;"><input type="text" class="form-control" valid-http="{{值}}" name="xuexi"/>
<small class="error" ng-show="myForm.xuexi</span><span style="font-size:14px;">.$error.number">
    *資料必須為純數字
</small></span>