按钮“已禁用”不适用于Recaptcha v3

问题描述

Recaptcha v3可以正常工作,但是最初,只有当用户单击复选框时,才必须禁用并启用“提交”按钮,但是发生的是,只有在两次单击复选框后才禁用提交按钮(单击以启用该按钮,另一个禁用它)。如果我删除recaptcha,一切正常。你能帮我吗?

这是我头脑中的Recaptcha脚本...

<script src="https://www.google.com/recaptcha/api.js"></script>
<script>
   function onSubmit(token) {
      document.getElementById("form").submit();
   }
</script>

这是我的表格...

<form id="form" name="form" action="PHP/submit.PHP" method="post" autocomplete="on">
   <div class="input-area">
      <label for="name">Name</label><br>
      <input type="text" class="input" id="name" name="name" placeholder="Write your full name...">
   </div>
   <div class="input-area">
      <label for="phone">Phone</label><br>
      <input type="tel" class="input" id="phone" name="phone" placeholder="Write your phone number..." required>
   </div>
   <div class="input-area">
      <label for="city">City</label><br>
      <input type="text" class="input" id="city" name="city" placeholder="Write your city..." required>
   </div>
   <div class="accept-terms">
      <input class="" type="checkBox" name="terms" id="terms" onChange="test(this);" />
      <label for="terms">I have read and accept the <a href="/terms.html" target="_blank">Terms and Conditions</a> as well as the <a href="/privacy.html" target="_blank">Privacy Policy</a>.
      </label>
   </div>
   <div>
      <button class="g-recaptcha my-button-class" data-sitekey="xxxx----my-site-key-here----xxxx" data-callback="onSubmit" data-action="submit" id="submit" name="submit" disabled>Submit</button>
   </div>
</form>

还有用于启用提交按钮的脚本...

<script language="JavaScript" type="text/javascript">
   function test(obj) {
      if (obj.checked)
         document.getElementById('submit').disabled = false;
      else
         document.getElementById('submit').disabled = true;
   }
</script>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...