<html>
<head>
<script src="https://ssl.captcha.qq.com/TCaptcha.js"></script>
<button onclick="submitFormWithCaptcha()">按钮</button>
</head>
</html>
<script>
function submitFormWithCaptcha() {
// 直接生成一个验证码对象
var captcha = new TencentCaptcha('你的CaptchaAppId', function (res) {
console.log(res)
if (res.ret === 0) {
alert("验证通过!");
}else{
return false;
}
});
// 显示验证码
captcha.show();
}
</script>
效果图展示
: