AngularJS 實(shí)現(xiàn)點(diǎn)擊按鈕獲取驗(yàn)證碼功能實(shí)例代碼
html :樣式采用了sui框架的樣式,請(qǐng)自行引入查看,AngularJS,自己引入,
<div ng-controller="forGetPassword" ng-app="routingDemoApp">
<form novalidate name="forget">
<header class="bar bar-nav">
<a href="javascript:history.go(-1);" rel="external nofollow" class="ui-header-btn ui-header-btn-sm"></a>
<h1 class='title'>忘記密碼</h1>
</header>
<div class="gorgetpassowrd">
<ul>
<li>
<input type="number" placeholder="請(qǐng)輸入您的手機(jī)號(hào)碼" required ng-model="mobile" name="mobile" ng-pattern="/^1[3|4|5|7|8]{1}[0-9]{9}$/">
</li>
<div ng-show="forget.mobile.$dirty && !forget.mobile.invalid">
<p class="textinfo" ng-show="forget.mobile.$error.required">手機(jī)號(hào)碼必填</p>
<p class="textinfo" ng-show="forget.mobile.$error.pattern">手機(jī)號(hào)碼格式不正確</p>
</div>
<li>
<input type="number" placeholder="驗(yàn)證碼" name="code" ng-model="code" required ng-minlength="6" ng-maxlength="6">
<a class="getCode paraclass" ng-click="getCode()" ng-bind="paracont" ng-disabled="paraevent"></a>
</li>
<div ng-show="forget.code.$dirty && !forget.code.invalid">
<p class="textinfo" ng-show="forget.code.$error.required">驗(yàn)證碼必填</p>
<p class="textinfo" ng-show="forget.code.$error.minlength">驗(yàn)證碼為6位數(shù)字</p>
<p class="textinfo" ng-show="forget.code.$error.maxlength">驗(yàn)證碼為6位數(shù)字</p>
</div>
</ul>
<p class="textinfo" ng-bind="mobiletest"></p>
<a class="button button-warning next-btn">下一步</a>
</div>
</form>
<div class="changePwd">
<form novalidate name="changePwd">
<ul>
<li>
<input type="password" placeholder="請(qǐng)輸入新密碼" required ng-model="newPwd" name="newPwd" ng-pattern="/^[a-zA-Z0-9]{6,20}/">
</li>
<div ng-show="changePwd.newPwd.$dirty && !changePwd.newPwd.invalid">
<p class="textinfo" ng-show="changePwd.newPwd.$error.required">密碼必須填</p>
<p class="textinfo" ng-show="changePwd.newPwd.$error.pattern">密碼由8-20位數(shù)字和字母組成</p>
</div>
<li>
<input type="password" placeholder="再次輸入新密碼" name="resetPwd" ng-model="resetPwd" >
</li>
<div ng-show="changePwd.newPwd.$valid">
<p class="textinfo" ng-show="newPwd != resetPwd">兩次輸入的密碼不一致</p>
</div>
</ul>
<a class="button button-warning next-btn">確認(rèn)修改</a>
</form>
</div>
</div>
<script>
var myCtrl = angular.module('routingDemoApp', ['ngRoute','infinite-scroll'])
myCtrl.controller('forGetPassword',function($scope,$interval){
$scope.paracont = "獲取驗(yàn)證碼";
$scope.paraclass = "but_null";
$scope.paraevent = true;
var second = null,timePromise = undefined;
$scope.getCode =function(){
var mobile = $scope.mobile;
if(second === null){
second = 60;
if(mobile == undefined || mobile ==""){
$scope.mobiletest = "請(qǐng)輸入手機(jī)號(hào)碼";
return false;
}else{
$scope.mobiletest = "";
timePromise = $interval(function(){
if(second<=0){
$interval.cancel(timePromise);
timePromise = undefined;
second = null;
$scope.paracont = "重發(fā)驗(yàn)證碼";
$scope.paraclass = "but_null";
$scope.paraevent = true;
}else{
$scope.paracont = second + "s";
second--;
}
},1000,100);
}
}else{
return false;
}
}
});
</script>
以上所述是小編給大家介紹的AngularJS 實(shí)現(xiàn)點(diǎn)擊按鈕獲取驗(yàn)證碼功能實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
詳解什么是@ngrx/store開發(fā)包中的MemoizedSelector
這篇文章主要為大家介紹了@ngrx/store開發(fā)包中的MemoizedSelector使用分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07
angular和BootStrap3實(shí)現(xiàn)購(gòu)物車功能
這篇文章主要為大家詳細(xì)介紹了angular和BootStrap3實(shí)現(xiàn)購(gòu)物車功能的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01
angularjs點(diǎn)擊圖片放大實(shí)現(xiàn)上傳圖片預(yù)覽
這篇文章主要為大家詳細(xì)介紹了angularjs點(diǎn)擊圖片放大實(shí)現(xiàn)上傳圖片預(yù)覽的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02
簡(jiǎn)介AngularJS中$http服務(wù)的用法
我們可以使用內(nèi)置的$http服務(wù)直接同外部進(jìn)行通信。$http服務(wù)只是簡(jiǎn)單的封裝了瀏覽器原生的XMLHttpRequest對(duì)象。接下來(lái)通過本文給大家簡(jiǎn)單介紹angularjs中http服務(wù)的用法,喜歡的朋友可以參考下2016-02-02
詳解angularjs獲取元素以及angular.element()用法
本篇文章主要介紹了詳解angularjs獲取元素以及angular.element()用法 ,具有一定的參考價(jià)值,有興趣的可以了解一下2017-07-07

