html+js 实验自动生成验证码并进行验证输入的正确

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>

<body>
<script>
    function run()
    {
        var a=new Array();
        for(var i=0;i<4;i++)
        {
            a[i]=Math.round(Math.random()*10%9);
        }
        var s=document.getElementById("t1");
        s.value=":"+a[0]+a[1]+a[2]+a[3];
    }
</script>
验证码为
<input type="text" id="t1"; style="width:1.5cm; border:0px"; value=":1234">
<input type="text" id="t2"; style="width:1.5cm" value="">
<button onClick="run()">看不清</button>
</body>
</html>

效果:


0

Leave a Reply

Your email address will not be published.