随机数
1 function checkCode(digit){ 2 //自动生成验证码 3 var result = ""; 4 for(var i = 0;i<parseInt(digit);i++){ 5 result = result+(parseInt(Math.random()*10)).toString(); 6 } 7 return result; 8 } 9 //自定义函数deal(),调用checkCode()函数将转换的字符串显示出来 10 function deal(){ 11 result.innerHTML=" 产生验证码:"+checkCode(form1.digit.value); 12 }
1 <input name = "Submit" type = "button" class="go-wenbenkuang" value = "生成" onclick="deal()">
按如上的方法可生成指定位数的验证码

浙公网安备 33010602011771号