主頁 > 知識(shí)庫 > jQuery Ajax顯示對號(hào)和錯(cuò)號(hào)用于驗(yàn)證輸入驗(yàn)證碼是否正確

jQuery Ajax顯示對號(hào)和錯(cuò)號(hào)用于驗(yàn)證輸入驗(yàn)證碼是否正確

熱門標(biāo)簽:Mysql連接數(shù)設(shè)置 銀行業(yè)務(wù) 科大訊飛語音識(shí)別系統(tǒng) 阿里云 服務(wù)器配置 電子圍欄 Linux服務(wù)器 團(tuán)購網(wǎng)站

廢話不多說了,直接給大家貼代碼了,具體代碼如下所示:

script src="js/j.js">/script>
script>
$(document).ready(function(e) {
 $('#yes').hide();
 $('#no').hide();
  $('input[name=gcode]').keyup(function(){
   if($(this).val().length==4){
  $.post('gbook.php',{cc:$('input[name=gcode]').val()},function(msg){
   
   if(msg=='yes'){
    $('#no').hide();
    $('#yes').show();
   }else{
    $('#yes').hide();
    $("#no").show();
   }
  });
  }
 });
});
/script>

首先引入jquery

.sl-error-verifycode {
 background-image: url("images/icons.png");
 background-position: -26px 0;
 background-repeat: no-repeat;
 display: block;
 font-size: 18px;
 height: 23px;
 line-height: 20px;
 margin-left: 180px;
 margin-top: -25px;
 position: relative;
 text-align: center;
 width: 20px;
 z-index: 2;
}
.sl-correct-verifycode {
 background-image: url("images/icons.png");
 background-position: -50px 0;
 background-repeat: no-repeat;
 display: block;
 font-size: 18px;
 height: 23px;
 line-height: 20px;
 margin-left: 180px;
 margin-top: -25px;
 position: relative;
 text-align: center;
 width: 20px;
 z-index: 2;
}

驗(yàn)證碼的html 代碼

tr>
  td height="40" align="right">驗(yàn)證碼:/td>
  td height="40">span class="addred">*/span>/td>
  td height="40">
  input type="text" name="gcode" id="textfield7" class="txtlist">
span id="yes" class="sl-correct-verifycode">/span>span id="no" class="sl-error-verifycode">/span>
  img style="float:right; margin-top:-25px; margin-right:300px;" align="middle" src="inc/cc.php" onClick="this.src='inc/cc.php?'+new Date" title="點(diǎn)擊換一張圖片" width="100px">/td>
 /tr>

gbook.php

?php
session_start();
if(isset($_POST['cc'])){
 $cc = strtolower($_POST['cc']);
 $ss = strtolower($_SESSION['code']);
 if($cc==$ss){
   echo "yes";
 }else{
   echo "no"; 
 }
}

注意圖片一定要引入

以上所述是小編給大家介紹的jQuery Ajax顯示對號(hào)和錯(cuò)號(hào)用于驗(yàn)證輸入驗(yàn)證碼是否正確,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!

您可能感興趣的文章:
  • Ajax和PHP正則表達(dá)式驗(yàn)證表單及驗(yàn)證碼
  • thinkphp驗(yàn)證碼的實(shí)現(xiàn)(form、ajax實(shí)現(xiàn)驗(yàn)證)
  • PHP生成各種常見驗(yàn)證碼和Ajax驗(yàn)證過程
  • jsp+ajax實(shí)現(xiàn)的局部刷新較驗(yàn)驗(yàn)證碼(onblur事件觸發(fā)較驗(yàn))
  • 基于Ajax用戶名驗(yàn)證、服務(wù)條款加載、驗(yàn)證碼生成的實(shí)現(xiàn)方法
  • asp.net ajax實(shí)現(xiàn)無刷新驗(yàn)證碼

標(biāo)簽:大理 衡水 萍鄉(xiāng) 江蘇 棗莊 廣元 衢州 蚌埠

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《jQuery Ajax顯示對號(hào)和錯(cuò)號(hào)用于驗(yàn)證輸入驗(yàn)證碼是否正確》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266