# XHTML Strict 1.0 valid reCaptcha

I’m currently working on a web which uses a contact form. To avoid Spam, I use reCaptcha which is a very good Captcha system (even better than the one I used for the blog comments). You can see it in action in the contact form of this blog.

The problem with the default reCaptcha output is that it does not validates XHTML 1.0 Strict because the use of iframes. But you can change the code at the recaptchalib.php file (available here). This problem persist at the current version (1.10 at this moment).

Replacing the code at lines #122 – #128 with:
[code lang=”php”]

‘;
?>
[/code]
will do the trick 😉

## 10 Replies to “XHTML Strict 1.0 valid reCaptcha”

1. Timo

Great job thanks!

Like or Dislike: 0  0

• Boriel

I’m not sure.. Maybe the reCaptcha code has change since I posted this code snippet?
Will check it anyway. Thank you!

Like or Dislike: 0  0

2. Torin Finnemann Jensen

Did you test it with javascript turned off? I’m not sure if it is due to other customization in my recaptcha setup, but the original code had these lines:

Without them, the user missed a field to post his response in on my site, when not having javascript enabled… The following works for me:
————————————————————————
return ‘

‘;
————————————————————————
Thanks for the patch though.!

/Torin

Like or Dislike: 0  0

3. craftymomma

oops… here is the code that was supposed to show

script type="text/javascript"

Like or Dislike: 0  0

4. craftymomma

😛 Thank you, Thank you! I’ve been looking for this all night. Now I can really tell my client that his site is strict xhtml. Works great.

For anyone changing the theme using the code on the recaptcha wiki be sure to add the java script type to the script tag. As it will cause an error.

IE

😉

Like or Dislike: 0  0

5. Boriel

Thanks, Kjetil! 😉 I forgot it.
Fixed.

Like or Dislike: 0  0

6. Kjetil Birkeland Moe

There is a </script> missing. Simply add it after the first script tag, and it validates.

Like or Dislike: 0  0

7. Boriel

Hi, Steven.

I’m sure. I’m not using it on this blog contact form (this is done by Deko Boko plugin), but on another site and it validates XHTML strict.

Perhaps the <script> tag should be closed with </script>. Can you test it?

Like or Dislike: 0  0

8. Steven

Hi Boriel,

Have you tested this yourself? Your has no closing tag and therefor is causing the page layout to break.

Like or Dislike: 0  0