<script>
function randomString(len) {
len = len || 32;
var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678.~!@$%&';
var maxPos = $chars.length;
var pwd = '';
for (i = 0; i < len; i++) {
pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
}
return pwd;
}
function setpassid(len,divid)
{
len = len || 32;
$(divid).val(randomString(len));
}
</script>
<span onclick="setpassid(20,divid)">[随机字符]</span>