最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

jQuery Ajax显示对号和错号用于验证输入验证码是否正确

来源:动视网 责编:小采 时间:2020-11-27 22:51:44
文档

jQuery Ajax显示对号和错号用于验证输入验证码是否正确

jQuery Ajax显示对号和错号用于验证输入验证码是否正确:废话不多说了,直接给大家贴代码了,具体代码如下所示: <script src=js/j.js></script> <script> $(document).ready(function(e) { $('#yes').hide(); $('#no').hide(); $('input[name
推荐度:
导读jQuery Ajax显示对号和错号用于验证输入验证码是否正确:废话不多说了,直接给大家贴代码了,具体代码如下所示: <script src=js/j.js></script> <script> $(document).ready(function(e) { $('#yes').hide(); $('#no').hide(); $('input[name


废话不多说了,直接给大家贴代码了,具体代码如下所示:

<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显示对号和错号用于验证输入验证码是否正确,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

文档

jQuery Ajax显示对号和错号用于验证输入验证码是否正确

jQuery Ajax显示对号和错号用于验证输入验证码是否正确:废话不多说了,直接给大家贴代码了,具体代码如下所示: <script src=js/j.js></script> <script> $(document).ready(function(e) { $('#yes').hide(); $('#no').hide(); $('input[name
推荐度:
标签: ajax jQuery ajax验证
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top