第一种是最笨的一种办法来实现验证码中既有数字又有大小写,第二种用unicode编码更方便一点,还顺便加了个验证刷新的作用,但刷新的是整个页面,同时还有个bug,就是数字及小写、大写的位置是固定的,更完美的写法请看后面的博客,谢谢!
<h4>随机生成4位验证码(randomCode 范围[a-z|0-9|A-Z])
arr = []
验证的时候,不区分大小写</h4>
<input type="text" id="aaa">
<button id="btn">验证</button>
<button onclick="window.location.reload()">刷新</button>
<script>
var aa = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
var bb = ['a', 'b', 'c', 'd', 'e', 'f', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
var cc = ["A", "B", "C", "D", "E",