관련 판독 값 :
jQuery를 기반으로 SMS 검증 코드를 전송 한 후 카운트 다운 기능이 실현됩니다 (페이지를 무시하고 닫습니다)
다음 코드는 편집자가 SMS 확인 코드를 귀하에게 전송 한 후 귀하에게 제공하는 코드입니다. 코드는 간단하고 이해하기 쉽습니다.
특정 코드는 다음과 같습니다.
<! docType html> <html lang = "en"> <head> <meta charset = "utf-8"> <meta name = "generator"content = "editplus®"> <meta name = "author"content = ""> <meta name = "keywords"content = "" "<meta name ="scrip ""> </title> <meta name = "scrip. src = "http://cdn.bootcss.com/jquery/3.1.0/jquery.js"> </script> <script src = "http://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js"> </script> </script> src = "// cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js">/script>--></head>< body>< input id ="phonenum "type ="text "value ="18518181818 "/> <입력 id ="second "" "버튼" /> </body> <cript> // 검증 코드를 보낼 때 CookieFunction 추가 추가 addCookie (이름, 값, expriershours) {// 만료 시간을 설정할지 여부를 판단합니다. 0은 브라우저를 닫을 때 유효하지 않음을 의미합니다. date.settime (date.gettime ()+Expireshours*1000); $ .cookie (이름, 탈출 (값), {xples : date}). date.settime (date.gettime ()+Expireshours*1000); // 단위는 milliseconds $ .cookie (이름, 탈출 (값), {xples : date});} else {$. 쿠키 (이름, 탈출 (value));}} // 이름 함수를 기준으로 쿠키의 값을 얻습니다. () {sendCode ($ ( "#second");}); v = getCookieValue ( "secondSremained"); // 쿠키 값을 가져옵니다. (v> 0) {settime ($ ( "#second"); // start countdown}}) // send verification code sendCode (obj) {phonenum = $ (var phonenum =); isphonenum (); if (result) {// dopostback ( '$ {base} /login/getcode.htm', backfunc1, { "phonenum": phonenum}); AddCookie ( "SeconsRemed", 60,60); // 쿠키 레코드 추가, 유효한 카운트 60 Settime (OBJ); // START- COUNT I); 함수 settime (obj) {countdown = getCookieValue ( "secondSpremained"); if (countdown == 0) {obj.removeattr ( "disabled"); obj.val ( "무료 획득 코드"); return;} else {obj.attr ( "disabled", true); obj.val ( "resend (" + countdown + ")"); countdown-; editCookie ( "secondSremained", countdown, countdown, countdown+1);} settimeout (function () {settime (obj)}, 1000) // 1000 milliseconds마다 실행됩니다} // 전화 번호가 법적 기능인지 확인합니다 isphonenum () {var phonenum = $ ( "#phonenum"); /^(((13 [0-9] {1}) | (15 [0-9] {1}) | (18 [0-9] {1}))+/d {8}) $/; if (! myreg.test (phonenum)) {alert ( '유효한 휴대 전화 번호를 입력하십시오!'); 거짓을 반환합니다. } else {return true;}} </script> </html>위는 편집기가 소개 한 JS를 기반으로 SMS 검증 코드를 전송 한 후 카운트 다운 기능입니다 (페이지 새로 고침을 무시하고 페이지가 닫히고 카운트 다운 기능이 수행되지 않음). 모든 사람에게 도움이되기를 바랍니다. 궁금한 점이 있으면 메시지를 남겨 주시면 편집자가 제 시간에 모든 사람에게 답장을 드리겠습니다. Wulin.com 웹 사이트를 지원해 주셔서 대단히 감사합니다!