導航:首頁 > 編程語言 > ngif在js里判斷

ngif在js里判斷

發布時間:2024-12-14 19:05:04

㈠ Angularjs 中 ng-if 能不能進行多條件判斷

當然可以,你可以網路一下,有很多的,包括elseif的用法,就不詳細說了。

㈡ angularjs 手機驗證怎麼寫

第一種方法:

<div class="form-group">
<label for="email" class="col-sm-4 control-label">電話:</label>
<div class="col-sm-4">
<input class="form-control" id="tel" placeholder="請輸入電話" type="tel" name="tel"
ng-model="userdata.tel" ng-minlength="11" ng-maxlength="11" ng-pattern="/^1[3|5][0-9]\d{4,8}$/"required>
</div>
<div class="col-sm-4">
<p class="glyphicon glyphicon-ok input_result text-success"
ng-if="signUpForm.tel.$valid"></p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="signUpForm.tel.$error.required&&signUpForm.tel.$touched">電話不能為空!</p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="(signUpForm.tel.$error.minlength||signUpForm.tel.$error.maxlength)&&signUpForm.tel.$touched">請輸入有效手機號!</p> <!--$touched失去焦點再做判斷-->
</div>
</div>
第二種方法:
<div class="form-group">
<label for="email" class="col-sm-4 control-label">電話:</label>
<div class="col-sm-4">
<input class="form-control" id="tel" placeholder="請輸入電話" type="tel" name="tel"
ng-model="userdata.tel" ng-minlength="11" ng-maxlength="11" ng-pattern="/^1[3|5][0-9]\d{4,8}$/"required>
</div>
<div class="col-sm-4">
<p class="glyphicon glyphicon-ok input_result text-success"
ng-if="signUpForm.tel.$valid&&signUpForm.tel.$error.pattern"></p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="signUpForm.tel.$error.required&&signUpForm.tel.$touched">電話不能為空!</p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="(signUpForm.tel.$error.minlength||signUpForm.tel.$error.maxlength)&&signUpForm.tel.$error.pattern&&signUpForm.tel.$touched">請輸入有效手機號!</p>
<!--$touched失去焦點再做判斷-->
</div>
</div>
第三種完全正確:(推薦)
<div class="form-group">
<label for="email" class="col-sm-4 control-label">電話:</label>
<div class="col-sm-4">
<input class="form-control" id="tel" placeholder="請輸入電話" type="tel" name="tel"
ng-model="userdata.tel" ng-minlength="11" ng-maxlength="11" ng-pattern="/^1[3|5][0-9]\d{4,8}$/"required>
</div>
<div class="col-sm-4">
<p class="glyphicon glyphicon-ok input_result text-success"
ng-if="signUpForm.tel.$valid"></p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="signUpForm.tel.$error.required&&signUpForm.tel.$touched">電話不能為空!</p>
<p class="text-danger glyphicon glyphicon-remove"
ng-if="(signUpForm.tel.$error.minlength||signUpForm.tel.$error.maxlength||signUpForm.tel.$error.pattern)&&signUpForm.tel.$touched">請輸入有效手機號!</p>
<!--$touched失去焦點再做判斷-->
</div>
</div>

閱讀全文

與ngif在js里判斷相關的資料

熱點內容
和家親app為什麼老是掉線 瀏覽:990
兒童編程思維課有什麼用 瀏覽:600
魔百和網路機頂盒怎麼連接電視 瀏覽:611
國產顯示器icc配置文件 瀏覽:52
java編程常見的語法糖有哪些 瀏覽:41
jspmysql選課源碼 瀏覽:877
ipadmini2下載app等待 瀏覽:399
creo工程圖配置文件 瀏覽:699
編程和鋼琴哪個貴 瀏覽:841
移動進銷存app哪個好 瀏覽:600
編程製作游戲什麼原理 瀏覽:97
linux如何查看是否有共享文件夾 瀏覽:264
u盤拷貝文件以後為空 瀏覽:917
快雲主機資料庫連接方法 瀏覽:756
javagsp定位 瀏覽:384
jsp頁面表格導出excel 瀏覽:976
imagetest教程 瀏覽:244
怎樣將一個cad文件包圖紙兼容 瀏覽:898
論文有什麼好的網站 瀏覽:581
jdk7javadoc 瀏覽:687

友情鏈接