如何隐藏启用 JavaScript 的浏览器的验证码并通过 html 验证

How to hide recaptcha for JavaScript enabled browsers and pass html validation

本文关键字:验证 浏览器 html JavaScript 何隐藏 隐藏 启用      更新时间:2023-09-26

我希望只对不支持JavaScript的浏览器使用recaptcha。 为此,我尝试使用 <noscript> 标签,如下所示。

<!DOCTYPE html>
<html>
    <head>
        <title>recaptcha</title>
    </head>
    <body>
        <noscript>
            <?php
                require_once('recaptcha-php-1.11/recaptchalib.php');
                echo recaptcha_get_html('xxx');
            ?>
        </noscript>
        <p>Done</p>
    </body>
</html>

使用 http://validator.w3.org 验证代码时,我收到以下错误:

Error Line 11, Column 11: The element noscript must not appear as a descendant of the noscript element.
    <noscript>
Error Line 12, Column 147: The frameborder attribute on the iframe element is obsolete. Use CSS instead.
…WAABIZRfA-fKq8eVkFjK_F" height="300" width="500" frameborder="0"></iframe><br/>

我能做些什么来消除这些错误(至少是第一个)? 另外,我是否最好检测JavaScript使用服务器端并且不回显验证码?

reCAPTCHA PHP 库会将进一步的