zoukankan      html  css  js  c++  java
  • 随机产生指定位数的验证码

    如图所示:

    随机产生指定位数的验证码的代码如下:
    <script language="javascript">
    function checkCode(digit){
     //自动生成验证码
     var result="";
     for(i=0;i<parseInt(digit);i++){
      result=result+(parseInt(Math.random()*10)).toString();
     }
     return result;
    }
    </script>
    <script language="javascript">
    function deal(){
     result.innerHTML="&nbsp;&nbsp;产生的验证码:"+checkCode(form1.digit.value);
    }
    </script>
     

    <body>
    <form name="form1" method="post" action="">
    <table width="271" height="178"  border="0" cellpadding="0" cellspacing="0" background="image/result.gif">
      <tr>
        <td valign="top"><table width="100%" height="150"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="15%" height="55">&nbsp;</td>
            <td width="69%" valign="bottom"><div id="result">&nbsp;&nbsp;产生的验证码:</div></td>
            <td width="16%">&nbsp;</td>
          </tr>
          <tr>
            <td height="68">&nbsp;</td>
            <td align="center">
                <br>
                请输入要产生的验证码的位数:<br>
                <br>
                <input name="digit" type="text" class="wenbenkuang" id="digit" value="4">
                (1-15)</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td align="center"><input name="Submit" type="button" class="go-wenbenkuang" value="生成" onClick="deal()">
              &nbsp;
              <input name="Submit2" type="button" class="go-wenbenkuang" value="刷新" onClick="window.location.reload();"></td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table>
    </form>
    </body>

  • 相关阅读:
    LeetCode12: 整数转罗马数字
    LeetCode11:盛最多水的容器
    LeetCode09:判断回文数
    LeetCode08:字符串转换成整数
    LeetCode04:寻找中位数
    LeetCode03:无重复字符的最长子串
    《JAVA编程思想》第四版 PDF 下载 中文版和英文版 高清PDF扫描带书签
    XML
    异常
    委托和匿名方法和Lambda表达式
  • 原文地址:https://www.cnblogs.com/paper/p/1533961.html
Copyright © 2011-2022 走看看