Guest User

Untitled

a guest
Aug 15th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Title</title>
  6. <style>
  7. *{
  8. margin: 0;
  9. padding: 0;
  10. }
  11. body{
  12. text-align: center;
  13. margin: 20% auto;
  14. }
  15. #input-text{
  16. padding: 5px 10px;
  17. }
  18. #send{
  19. background: #0c80ba;
  20. height: 30px;
  21. text-align: center;
  22. border: none;
  23. width: 80px;
  24. color: #fff;
  25. }
  26. </style>
  27. <script>
  28. var is_mobile=function (str) {
  29. return /^(86)?1[3,4,5,7,8]\d{9}$/.test(str);
  30. };
  31. var interVal=function (o) {
  32. var that = this;
  33. var _secs = 60;
  34. var sendbtn=document.getElementById('send');
  35. var text=document.getElementById('input-text');
  36. if(!is_mobile(text.value)){
  37. alert('请输入合法手机号');
  38. }else{
  39. sendbtn.innerText=_secs + 's';
  40. sendbtn.disabled=true;
  41. that = setInterval(function () {
  42. _secs--;
  43. sendbtn.innerText=_secs + 's';
  44. if (_secs <= 0) {
  45. sendbtn.innerText='重新发送';
  46. sendbtn.disabled=false;
  47. clearInterval(that);
  48. }
  49. }, 1000);
  50. }
  51. };
  52. </script>
  53. </head>
  54. <body>
  55. <input type="text" id="input-text" placeholder="请输入">
  56. <button type="button" id="send" onclick="interVal()">发送</button>
  57. </body>
  58. </html>
Add Comment
Please, Sign In to add comment