废话不多说了,直接给大家贴代码了,具体代码如下所示:
<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; }
验证码的html 代码
<tr> <td height="40" align="right">验证码:</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="点击换一张图片" 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显示对号和错号用于验证输入验证码是否正确,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对尊托云数网站的支持!
选择排序 定义 一种最简单的排序算法是这样的假定我们对一个数组进行排序那么我...
这几天做一个项目,是写一个语句,将D盘的文件全部移动到E盘去,在本地XP环境下...
本文是对之前开发中遇到的问题的一个总结,文章其实早就写好,但是觉得自己写得...
微软将会在今年下半年发布的Windows10 21H2中,使用全新设计的UI界面,以改变Win...
ClickHouse 是 Yandex(俄罗斯最大的搜索引擎)开源的一个用于实时数据分析的基...
随着国际环境日趋复杂,数据安全与信息技术发展成为发展首要任务。目前,随着信...
场景 当我提交了本次修改到本地和远程分支后,发现我本次提交还少了一些修改内容...
详解hibernate自动创建表的配置 配置自动创建表: prop key="hibernate.hbm2ddl....
一般情况下,aspnetcore发布后的默认端口是5000,这个大家都知道,而且默认骨架...
如何终止浏览器的 Cahce 页面? Function Redirect( NewURL ) If Not IsEmpty( N...