成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

js如何實現(xiàn)手機發(fā)送驗證碼功能

這篇文章將為大家詳細講解有關(guān)js如何實現(xiàn)手機發(fā)送驗證碼功能,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

網(wǎng)站的建設創(chuàng)新互聯(lián)專注網(wǎng)站定制,經(jīng)驗豐富,不做模板,主營網(wǎng)站定制開發(fā).小程序定制開發(fā),H5頁面制作!給你煥然一新的設計體驗!已為塔吊租賃等企業(yè)提供專業(yè)服務。

效果圖:

js如何實現(xiàn)手機發(fā)送驗證碼功能

代碼如下:

<!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>發(fā)送驗證碼倒計時功能</title>
<style>
@charset "utf-8";
*{ margin:0; padding:0; list-style:none}
body{ background:#EBECED; font-family:'微軟雅黑'}
.form{width: 450px;height: auto; margin:100px auto; overflow:hidden;font-size: 16px;color: #1b1b1b;text-align: left; padding:50px; border:1px solid #ccc; border-radius:10px;}
.form div{padding:5px 0;overflow: hidden;}
.form label{width: 90px;display: block;float: left;}
.form .infos{width:200px;height: 26px;line-height: 26px;border:1px solid #BFBFBF;padding:2px;border-radius:4px;float: left;}
.form .div-phone a.send1{height: 26px;text-decoration:none;line-height: 26px;padding:2px;width: 80px;background: #AA8926;font-family: '宋體';color: #fff;font-size: 12px;text-align: center;display: block;float: left;border-radius:2px;margin-left:2px;-webkit-transition:all 0.2s linear;-moz-transition:all 0.2s linear;-ms-transition:all 0.2s linear;-o-transition:all 0.2s linear;transition:all 0.2s linear;}
.form .div-phone a.send1:hover{text-decoration: none;background: #866c1b;-webkit-transition:all 0.2s linear;-moz-transition:all 0.2s linear;-ms-transition:all 0.2s linear;-o-transition:all 0.2s linear;transition:all 0.2s linear;}
.form .div-phone a.send0{height: 26px;text-decoration:none;line-height: 26px;padding:2px;width: 80px;background: #A1A1A1;font-family: '宋體';color: #fff;font-size: 12px;text-align: center;display: block;float: left;border-radius:2px;margin-left:2px;}
.form .div-phone a.send0:hover{background: #A1A1A1;font-family: '宋體';color: #fff;font-size: 12px;text-decoration: none;}
.form span.error{height: 26px;line-height: 26px;padding:2px;width: 100px;color: red;padding-left:20px;display: block;float: left;margin-left:10px;font-size: 12px;font-family: '宋體';background: url(../images/error.png) no-repeat left center;}
.form #phone{width: 116px;}
.form .div-conform{padding-right:153px;}
.form .div-conform a.conform{width: 136px;height: 34px;display: block;text-align: left;overflow: hidden;background: url(../images/btn.jpg) no-repeat;float: right;text-indent: -1000px;}
</style>
</head>
<body>
<!--代碼部分begin-->
<div class="form">
 <div class="div-name">
 <label for="name">用戶名</label><input type="text" id="name" class="infos" placeholder="請輸入用戶名" />
 </div>
 <div class="div-phone">
 <label for="phone">手機</label><input type="text" id="phone" class="infos" placeholder="請輸入手機" />
 <a href="javascript:;" rel="external nofollow" rel="external nofollow" class="send1" onclick="sends.send();">發(fā)送驗證碼</a>
 </div>
 <div class="div-ranks">
 <label for="ranks">驗證碼</label><input type="text" id="ranks" class="infos" placeholder="請輸入驗證碼" />
 </div>
 <div class="div-conform">
 <a href="javascript:;" rel="external nofollow" rel="external nofollow" class="conform" onclick="sends.conform();">提交</a>
 </div>
</div>
<script src="http://www.lanrenzhijia.com/ajaxjs/jquery.min.js"></script>
<script>
var sends = {
 checked:1,
 send:function(){
  var numbers = /^1\d{10}$/;
  var val = $('#phone').val().replace(/\s+/g,""); //獲取輸入手機號碼
  if($('.div-phone').find('span').length == 0 && $('.div-phone a').attr('class') == 'send1'){
  if(!numbers.test(val) || val.length ==0){
   $('.div-phone').append('<span class="error">手機格式錯誤</span>');
   return false;
  }
  }
  if(numbers.test(val)){
  var time = 30;
  $('.div-phone span').remove();
  function timeCountDown(){
   if(time==0){
   clearInterval(timer);
   $('.div-phone a').addClass('send1').removeClass('send0').html("發(fā)送驗證碼");
   sends.checked = 1;
   return true;
   }
   $('.div-phone a').html(time+"S后再次發(fā)送");
   time--;
   return false;
   sends.checked = 0;
  }
  $('.div-phone a').addClass('send0').removeClass('send1');
  timeCountDown();
  var timer = setInterval(timeCountDown,1000);
  }
 }
}
</script>
</body>
</html>

關(guān)于“js如何實現(xiàn)手機發(fā)送驗證碼功能”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

當前題目:js如何實現(xiàn)手機發(fā)送驗證碼功能
URL鏈接:http://jinyejixie.com/article22/ppedcc.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、外貿(mào)建站、網(wǎng)站排名網(wǎng)站制作、網(wǎng)站設計公司、網(wǎng)站維護

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設計公司
乐亭县| 来宾市| 肥乡县| 越西县| 隆化县| 绥江县| 大宁县| 凌源市| 兴业县| 湘乡市| 确山县| 尤溪县| 莱芜市| 黑龙江省| 东乌珠穆沁旗| 湘乡市| 郑州市| 克什克腾旗| 锦州市| 宜川县| 内黄县| 奈曼旗| 北流市| 葵青区| 嘉鱼县| 花莲市| 奉贤区| 耒阳市| 甘孜县| 墨玉县| 滦南县| 安新县| 广饶县| 高州市| 林周县| 聂荣县| 和田市| 巴林右旗| 云霄县| 钦州市| 浠水县|