這學期剛學的用javascript實現隨機產生驗證碼過程(非圖片驗證碼)

來源:互聯網
上載者:User

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>javascript指令碼語言(動態切換和驗證碼練習)</title><style type="text/css">*{ margin:0px auto;}#top{ width:960px;}#nav{ background-image:url(../image1/login_head.gif); background-repeat:no-repeat; width:360px; height:25px; margin-top:20px; padding-left:20px; color:#FFF; padding-top:3px;}#main{ width:380px; height:340px; text-align:center; font-size:14px; border:1px #009; background:#09F;}#qqtop1{ float:left; width:100px; height:18px; padding-top:5px;}#qqtop2{ width:280px; height:20px; float:right; }#right{ float:left;}.font{ color:#F0F;font-size:30px;font-family:微軟雅黑; }</style><script type="text/javascript"> function chang(num) {     if(num==1)     {        document.getElementById("qid").style.display="none";        document.getElementById("qqh").style.display="block";        document.getElementById("qqm").style.display="block";          }else     {        document.getElementById("qid").style.display="block";        document.getElementById("qqh").style.display="none";        document.getElementById("qqm").style.display="none";          } }  var str=""; function radom()//顯示驗證碼方法 {    var j=new Array("0","1","2","3","8","9","a","b","c","d");        for(var i=0;i<4;i++)    {        var num=parseInt(Math.random()*j.length);        str+=j[num];        }        document.getElementById("yzm").innerHTML=str;    document.getElementById("yzm").className="font"; }  function gb() {     str="";    radom();      } function ok(){     var yzm=document.getElementById("yzm").innerHTML.toUpperCase();      str=document.getElementById("yz").value;    if(yzm==str.toUpperCase())    {        alert("登入成功!");        }else    {        alert("my god!驗證碼錯誤,請從新輸入!");        gb();        }    }</script>    </head><body onload="radom()"><div id="top"><img src="../image1/top.jpg" /></div><div id="nav">拍拍使用者登入</div><div id="main"><div id="qqtop1">登入方式選擇:</div><div id="qqtop2">  <input type="radio" name="checd" checked="checked" onclick="chang(1)" />QQ號碼登入<input type="radio" name="checd" onclick="chang(0)" />QQ群號登入</div><br/><div id="qqh" style="margin-top:30px;">QQ號碼:<input type="text" />忘記QQ號碼〉〉</div><br/><div id="qid" javascript: style="display:none; padding-right:90px;" >QQ群Id:<input type="text"  /></div><div id="qqm">QQ密碼:<input type="password" />忘記QQ密碼〉〉</div><br/><br/><div  style=" padding-right:90px;" >驗證碼:<input type="text" value="請輸入顯示的文字" id="yz" /></div><br/><div id="qqh" style=" padding-right:110px; color:#00F;"><label onclick="gb()">看不清,換一張</label></div><br/><div style="height:40px; width:100px; background-color:#03F; padding-top:20px; margin-left:100px;" ><label id="yzm"></label></div><br/><input type="button" value="登&nbsp;&nbsp;錄" style="background-color:#03F; padding-top:5px; margin-right:80px; height:30px; width:100px" onclick="ok()" /></div></body></html>

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.