我已经为此斗争了很长时间。我跟随一些为.Net使用不可见reCAPTCHA的示例,但是当我尝试在现有项目中实现它们时,出现错误“ bind参数必须是元素或id”。这是一个代码段。
<asp:PlaceHolder ID="phContinueDefault" Visible="true" runat="server">
<br />
<br />
<div id="invisibleRecaptcha" class="g-recaptcha" data-sitekey="6LdWTnEUAAAAADdWMR62MPzqlPMd2T8xxJpc5oVP" data-bind="btnContinueDefault" data-callback="onSuccess" ></div>
<script>
var onSuccess = function (response) {
debugger;
var errorDivs = document.getElementsByClassName("recaptcha-error");
if (errorDivs.length) {
errorDivs[0].className = "";
}
var errorMsgs = document.getElementsByClassName("recaptcha-error-message");
if (errorMsgs.length) {
errorMsgs[0].parentNode.removeChild(errorMsgs[0]);
}
var clickButton = document.getElementById("<%= btnContinueDefault.ClientID %>");
clickButton.click();
};
</script>
<button id="btnContinueDefault" type="submit" isdefault="true" class="next btn btn-primary btn-md" onserverclick="btnContinue_OnClick" runat="server">Continue <span class="glyphicon glyphicon-arrow-right"></span></button>
</asp:PlaceHolder>
如您所见,我正在尝试将其绑定到已经存在的html按钮,其想法是在按钮单击时实现它,然后如果有效,请移至下一页。帮助吗?