Google reCAPTCHA使用小心得

這是google推出的驗證表單工具,非常簡單好用,先到這裡申請一個reCAPTCHA,填寫相關資料,看一下文件跟網路上資料,下面是簡單的使用

<html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title>reCAPTCHA demo: Simple page</title>
 <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20type%3D%22text%2Fjavascript%22%3E%0A%20function%20check_form()%7B%0A%20var%20response%20%3D%20grecaptcha.getResponse()%3B%0A%20if(response.length%20%3D%3D%200)%0A%20alert('%E6%9C%AA%E9%80%9A%E9%81%8E%E9%A9%97%E8%AD%89')%3B%0A%20else%20alert('%E5%B7%B2%E9%80%9A%E9%81%8E%E9%A9%97%E8%AD%89')%3B%0A%20%7D%0A%20%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
 <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="%3Cscript%20src%3D%22https%3A%2F%2Fwww.google.com%2Frecaptcha%2Fapi.js%22%20async%20defer%3E%3C%2Fscript%3E" data-mce-resize="false" data-mce-placeholder="1" class="mce-object" width="20" height="20" alt="&lt;script&gt;" title="&lt;script&gt;" />
 </head>
 <body>
 

<form action="javascript:check_form()" method="POST">
 

<div class="g-recaptcha" data-sitekey="6LfoLiYTAAAAAKIVeYFA8S0vJcrip_QUyt61LIuo"></div>


 
 <input type="submit" value="Submit">
 </form>


 </body>
</html>

記得改your_site_key,如果都沒錯的話,按下submit即可看到驗證結果摟

這個判斷方法是到這裡看的

Leave a Reply

你的電子郵件位址並不會被公開。