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

I want to use recaptcha only for browsers that do not support JavaScript. To do this, I tried using the <noscript> , as shown below.

 <!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> 

When checking the code using http://validator.w3.org, I received the following errors:

 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/> 

Is there anything I can do to remove these errors (at least the first one)? Also, am I better off disabling JavaScript using serveride and just not repeating the captcha?

+1
source share
1 answer

The PHP RECAPTCHA library will provide an additional <noscript> to the DOM inside the existing one, invoking invalid HTML code because by default it uses javascript.

Look here - Mapping reCAPTCHA without plugins - In particular, the section "Mapping reCAPTCHA without plugins". It shows you an example of what HTML markup should look like. You can try just pasting the code in noscript tags ...

 <iframe src="http://www.google.com/recaptcha/api/noscript?k=your_public_key" height="300" width="500" frameborder="0"></iframe><br> <textarea name="recaptcha_challenge_field" rows="3" cols="40"> </textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge"> 
+1
source

Source: https://habr.com/ru/post/956620/


All Articles