亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

如何在登錄頁面引入驗(yàn)證碼文件并顯示

上一章節(jié)介紹如何制作一個(gè)簡單的驗(yàn)證碼,把驗(yàn)證碼的php文件定義為:captcha.php

現(xiàn)在我們來說一說如何引入驗(yàn)證碼文件,初始我們的登錄頁面是這樣的:

25.png

這里的驗(yàn)證碼是這樣的。

login.html 文件中的代碼如下:

<div class="form-group">
    <div class="field">
        <input type="text" class="input input-big" name="code" placeholder="填寫右側(cè)的驗(yàn)證碼" data-validate="required:請?zhí)顚懹覀?cè)的驗(yàn)證碼" />
       <img src="images/passcode.jpg" alt="" width="100" height="32" class="passcode" style="height:43px;cursor:pointer;" onclick="this.src=this.src+'?'">  
                               
    </div>
</div>

這里我們需要對這段代碼進(jìn)行一些修改,引入驗(yàn)證碼文件,修改后的代碼如下

<div class="form-group">
   <div class="field">
      <input type="text" class="input input-big" name="code" placeholder="填寫驗(yàn)證碼" data-validate="required:請?zhí)铗?yàn)證碼" />
      <a style="float:right; padding:5px;" href="javascript:;" onclick="document.getElementById('captcha_img').src='captcha.php?r='+Math.random()">
         <img id="captcha_img" class="passcode" border='1' src='captcha.php?r=echo rand(); ?>' style="width:100px; height:42px" />
      </a>
   </div>
</div>

然后對css樣式進(jìn)行一些修改。這里使用了javascript中的HTML DOM Document 對象,并引用了captcha.php的驗(yàn)證碼生成的圖片。

運(yùn)行代碼后實(shí)現(xiàn)的效果:

26.png




繼續(xù)學(xué)習(xí)
||
<div class="form-group"> <div class="field"> <input type="text" class="input input-big" name="code" placeholder="填寫驗(yàn)證碼" data-validate="required:請?zhí)铗?yàn)證碼" /> <a style="float:right; padding:5px;" href="javascript:;" onclick="document.getElementById('captcha_img').src='captcha.php?r='+Math.random()"> <img id="captcha_img" class="passcode" border='1' src='captcha.php?r=echo rand(); ?>' style="width:100px; height:42px" /> </a> </div> </div>
提交重置代碼