Easy Captcha javascript script


A little soft easy and user-friendy captcha, instead of sometimes hard reading captcha we can view in some sites.

Captcha number is created by a javascript client-side script, and inserted in a hidden input field.


You can run a double check:

client-side: check if random js number is the same value of hidden field

server-side: checking fields url.captcha and url.captchaHidden


Test page : captcha.cfm (a standard HTML page, without server-side script).

Let check it 🙂

<script language="javascript">
function myLayer (x){
//object finding
if(document.layers){ // browser="NN4";
if(document.all){ // browser="IE";
lay=eval("document.all." + x);
if(!document.all && document.getElementById){ // browser="NN6+ or IE5+ if you’re willing to dump the !document.all stuff";
return lay;
function fnCaptcha(){
var numero=Math.random()*7*666;
var numero=Math.floor(numero);

myLayer("captchaNumber").innerHTML = numero;

document.frmCaptcha.captchaHidden.value = numero;
function fnCaptchaCheck(f){
if ((f.captcha.value == "") || (f.captcha.value == f.captchaHidden.value)){
alert("Different numbers. Check KO ");
alert("Same numbers. Check OK. ");
return false();

<h3>Prova Captcha</h3>
Insert number you can see between brackets (<span id="captchaNumber"></span>)<br />
<form id="frmCaptcha" name="frmCaptcha" method="post" action="" onsubmit="return fnCaptchaCheck(this)">
<input name="captcha" type="text" id="captcha" />
<input name="captchaHidden" type="hidden" id="captchaHidden" />
<input type="button" name="Submit" value="Pulsante" />
<br />

To improve security level, you can translate form from get post, to form post.



Loading Facebook Comments ...

2 pensieri su “Easy Captcha javascript script

  1. Mauricio Roman

    (f.captcha.value == f.captchaHidden.value)

    should be

    (f.captcha.value !== f.captchaHidden.value)

    or am I missing something?


Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *