• 随机产生指定位数的验证码


    如图所示:

    随机产生指定位数的验证码的代码如下:
    <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>

  • 相关阅读:
    带CheckBox的dojo Tree简单实现,并实现级联选取
    dojox.grid.EnhancedGrid
    Java内存模型及GC原理
    团队任务(第三次)
    团队任务二
    团队任务(一)
    词频统计及其效能分析
    贪吃蛇
    第一课
    软工七组团队2-1作业
  • 原文地址:https://www.cnblogs.com/paper/p/1533961.html
Copyright © 2020-2023  润新知