[英]google captcha from jquery to vanilla javascript
我创建了这个片段来验证我的 Google Captcha 表单。 这是在 Jquery 中完成的,但希望将其更改为普通 Javascript。 我在网上找到了一些资源,但无法正确获取,这里是其中之一: https://tobiasahlin.com/blog/move-from-jquery-to-vanilla-javascript/
这是我在 Jquery 中的工作片段,我如何将其更改为 Vanilla Javascript?
$('.contact-form').on('submit', function(e) {
if(grecaptcha.getResponse() == "") {
e.preventDefault();
$( '.msg-error').text( "Tick to confirm you are human" )}});
我设法解决了它。 感谢您的参考@user7290583。
document.querySelector('.contact-form').addEventListener('submit', (e) => {
if(grecaptcha.getResponse() == "") {
e.preventDefault();
errorMsg = document.getElementById("msg-error");
errorMsg.textContent = "Please tick box to confirm you are not a robot";
}});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.