如何在此表单中制作reCaptcha?
问题描述:
我该如何做到这一点?
HTML表单代码:如何在此表单中制作reCaptcha?
<div id="myDIV" style="">
<form name="login">
<h2 style="position:relative;right:107;bottom:10">Sign in</h2><p style="position:relative;right:55;bottom:5">to NASP Stacks database</p>
<input class="input" name="id" type="text" placeholder="Username"><br><br>
<input name="pass" type="password" class="input" placeholder="Password"><br><br>
<script>
{
"success": true|false,
"challenge_ts": timestamp, // timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ)
"hostname": string, // the hostname of the site where the reCAPTCHA was solved
"error-codes": [...] // optional
}
</script>
<div class="g-recaptcha" data-sitekey="6LdHRDgUAAAAAFg8efAOvTVM_9crHq_UQm_aveaW"></div><br>
<b><input class="button" type="button" value="NEXT" onClick="pasuser(this.form)"></b>
</form>
</div>
我怎样才能让reCAPTCHA的这种形式必填字段?我尝试了其他帖子,但他们没有工作。我之前添加了很多东西,但他们没有工作,他们堵塞了代码。任何人都知道如何使它成为必需的?
答
只需添加required
到您的输入:
<input class="button" type="button" value="NEXT" onClick="pasuser(this.form)" required>
注:我不明白你的脚本代码:/
答
你见过此相关的职位? reCaptcha field as required
我相信你需要有一个Javascript回调函数来验证recaptcha的响应才能继续。由于您的表单没有提交输入,我想您需要在onClick事件的回调函数中进行验证。
onClick="pasuser(this.form)"