第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何使用javascript / jQuery驗(yàn)證Google reCAPTCHA v2?

如何使用javascript / jQuery驗(yàn)證Google reCAPTCHA v2?

胡子哥哥 2019-11-12 10:12:58
我在aspx中有一個(gè)簡(jiǎn)單的聯(lián)系表。我想在提交表單之前驗(yàn)證reCaptcha(客戶(hù)端)。請(qǐng)幫忙。樣例代碼:    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>    <!DOCTYPE html>    <html xmlns="http://www.w3.org/1999/xhtml">    <head runat="server">        <title>Test Form</title>        <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">        <script src="//code.jquery.com/jquery-1.10.2.js"></script>        <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>        <link rel="stylesheet" href="/resources/demos/style.css">        <script src="https://www.google.com/recaptcha/api.js" async defer></script>        <script>            $("#cmdSubmit").click(function () {                //need to validate the captcha            });        </script>     </head>    <body>        <form id="form1" runat="server">            <label class="clsLabe">First Name<sup>*</sup></label><br />            <input type="text" id="txtFName" name="txtFName" class="clsInput" /><br />            <div class="g-recaptcha" data-sitekey="my_key"></div>            <img id="cmdSubmit" src="SubmitBtn.png" alt="Submit Form" style="cursor:pointer;" />        </form>    </body>    </html>我想cmdSubmit點(diǎn)擊驗(yàn)證驗(yàn)證碼。
查看完整描述

3 回答

?
慕桂英3389331

TA貢獻(xiàn)2036條經(jīng)驗(yàn) 獲得超8個(gè)贊

reCaptcha的客戶(hù)端驗(yàn)證-以下對(duì)我有用:


如果未在客戶(hù)端對(duì)reCaptcha進(jìn)行驗(yàn)證,則“ grecaptcha.getResponse();”將返回null,否則返回非null的值。


JavaScript代碼:


var response = grecaptcha.getResponse();


if(response.length == 0)

    //reCaptcha not verified


else

    //reCaptch verified


查看完整回答
反對(duì) 回復(fù) 2019-11-12
?
藍(lán)山帝景

TA貢獻(xiàn)1843條經(jīng)驗(yàn) 獲得超7個(gè)贊

使用此工具可通過(guò)簡(jiǎn)單的javascript驗(yàn)證Google驗(yàn)證碼。


html主體中的這段代碼:


<div class="g-recaptcha" id="rcaptcha" style="margin-left: 90px;" data-sitekey="my_key"></div>

<span id="captcha" style="margin-left:100px;color:red" />

這段代碼放在調(diào)用get_action(this)方法表單按鈕的開(kāi)頭:


function get_action(form) 

{

    var v = grecaptcha.getResponse();

    if(v.length == 0)

    {

        document.getElementById('captcha').innerHTML="You can't leave Captcha Code empty";

        return false;

    }

    else

    {

        document.getElementById('captcha').innerHTML="Captcha completed";

        return true; 

    }

}


查看完整回答
反對(duì) 回復(fù) 2019-11-12
  • 3 回答
  • 0 關(guān)注
  • 1005 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)