国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery Real Person驗證碼插件防止表單自動提交

2019-11-20 11:19:58
字體:
來源:轉載
供稿:網友

本文介紹的jQuery插件有點特殊,防自動提交表單的驗證工具,就是我們經常用到的驗證碼工具,先給大家看看效果。

效果圖如下:


使用說明
需要使用jQuery庫文件和Real Person庫文件
同時需要自定義驗證碼顯示的CSS樣式

使用實例

1、包含文件部分
<script type="text/javascript" src="jquery-latest.pack.js"></script>
<script type="text/javascript" src="jquery.realperson.js"></script>
<style type="text/css">@import "jquery.realperson.css";</style>
2、HTML部分
<input type="text" id="biuuu" name="defaultReal">
3、Javascript部分
$("#biuuu").realperson();
如上實例,就可以實現一個防自動提交表單的驗證碼工具,同時可指定驗證碼字符的長度,如下:
$("#biuuu").realperson({length: 5});

今天所講到的jQuery Real Person Plugin,就是一個完全由JavaScript編寫而成的jQuery驗證碼插件。

jQuery插件Real Person 點擊可刷新實例講解

<!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>Untitled Document</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.realperson.js"></script> <link href="jquery.realperson.css" rel="stylesheet" type="text/css" /> <script type="text/javascript">   $(function(){     $('#Gideon').realperson({length: 5});   }) </script> </head>  <body>  <input type="text" id="Gideon" name="defaultReal"> </body> </html>  

注:如果持續無法驗證成功的話,請嘗試下面的方法:

<?php function rpHash($value) {   $hash = 5381;   $value = strtoupper($value);   for($i = 0; $i < strlen($value); $i++) {     $hash = (($hash << 5) + $hash) + ord(substr($value, $i));   }   return $hash; } ?>  

替換為:

<?   function rpHash($value)    {     $hash = 5381;     $value = strtoupper($value);     for($i = 0; $i < strlen($value); $i++) $hash = (leftShift32($hash, 5) + $hash) + ord(substr($value, $i));     return $hash;    }    function leftShift32($number, $steps)    {     $binary = decbin($number);     $binary = str_pad($binary, 32, "0", STR_PAD_LEFT);     $binary = $binary.str_repeat("0", $steps);     $binary = substr($binary, strlen($binary) - 32);     return ($binary{0} == "0" ? bindec($binary) : -(pow(2, 31) - bindec(substr($binary, 1))));    } ?> 

以上就是為大家介紹了jQuery驗證碼插件Real Person的使用方法,小編整理的可能有些不全面,希望大家多多諒解。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 灵山县| 错那县| 邓州市| 东山县| 承德市| 淮安市| 探索| 宝山区| 文水县| 明光市| 旬阳县| 洞头县| 霍林郭勒市| 靖州| 雷州市| 平顶山市| 临泽县| 高雄市| 昭觉县| 唐海县| 海林市| 三门县| 久治县| 云梦县| 镇巴县| 土默特左旗| 浠水县| 肇庆市| 梧州市| 阿勒泰市| 萍乡市| 革吉县| 盐池县| 永登县| 林州市| 观塘区| 茂名市| 德惠市| 五大连池市| 宁明县| 阿坝|