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)文章
Angular.js自動(dòng)化測(cè)試之protractor詳解
Protractor是一個(gè)建立在WebDriverJS基礎(chǔ)上的端到端(E2E)的AngularJS JavaScript Web應(yīng)用程序測(cè)試框架,下面這篇文章主要給大家介紹了angular.js自動(dòng)化測(cè)試之protractor的相關(guān)資料,需要的朋友可以參考下。2017-07-07
將angular-ui的分頁(yè)組件封裝成指令的方法詳解
這篇文章主要給大家介紹了將angular-ui的分頁(yè)組件封裝成指令的方法,文中介紹的非常詳細(xì),相信會(huì)對(duì)大家的學(xué)習(xí)或者工作覺有一定的參考價(jià)值,需要的朋友下面來一起看看吧。2017-05-05
解決angularjs WdatePicker ng-model的問題
今天小編就為大家分享一篇解決angularjs WdatePicker ng-model的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-09-09
AngularJS使用Filter自定義過濾器控制ng-repeat去除重復(fù)功能示例
這篇文章主要介紹了AngularJS使用Filter自定義過濾器控制ng-repeat去除重復(fù)功能,結(jié)合實(shí)例形式分析了AngularJS自定義過濾器的定義及數(shù)組過濾相關(guān)操作技巧,需要的朋友可以參考下2018-04-04
詳解Angular 4.x 動(dòng)態(tài)創(chuàng)建組件
本篇文章主要介紹了詳解Angular 4.x 動(dòng)態(tài)創(chuàng)建組件,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-04-04
Angular應(yīng)用Bootstrap過程步驟邏輯詳解
這篇文章主要為大家介紹了Angular應(yīng)用Bootstrap過程步驟邏輯詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07
Angularjs實(shí)現(xiàn)下拉框聯(lián)動(dòng)的示例代碼
本篇文章主要介紹了Angularjs下拉框聯(lián)動(dòng)的示例代碼,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-08-08
Angular依賴注入optional?constructor?parameters概念
這篇文章主要為大家介紹了Angular?依賴注入領(lǐng)域里?optional?constructor?parameters?的概念及使用,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-11-11
探索angularjs+requirejs全面實(shí)現(xiàn)按需加載的套路
這篇文章主要探索了angularjs+requirejs全面實(shí)現(xiàn)按需加載的套路,圍繞angularjs提供的各種機(jī)制進(jìn)行研究,感興趣的小伙伴們可以參考一下2016-02-02

