jQuery Real Person驗證碼插件防止表單自動提交
本文介紹的jQuery插件有點特殊,防自動提交表單的驗證工具,就是我們經(jīng)常用到的驗證碼工具,先給大家看看效果。
效果圖如下:
使用說明
需要使用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();
如上實例,就可以實現(xiàn)一個防自動提交表單的驗證碼工具,同時可指定驗證碼字符的長度,如下:
$("#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>
注:如果持續(xù)無法驗證成功的話,請嘗試下面的方法:
<?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的使用方法,小編整理的可能有些不全面,希望大家多多諒解。
相關文章
jquery實現(xiàn)獲取具體時間(年月日)后3個月+1天的年月日
這篇文章主要為大家詳細介紹了jquery如何實現(xiàn)獲取具體時間(年月日)后3個月+1天的年月日,文中的示例代碼講解詳細,有需要的小伙伴可以參考一下2023-11-11ASP.NET MVC中EasyUI的datagrid跨域調(diào)用實現(xiàn)代碼
因為easyUI使用的是JQuery的異步方法加載數(shù)據(jù),應該遵循JQuery的跨域訪問規(guī)則2012-03-03