How to create simple javascript/jquery client side captcha? How it may be realize, thx.
What is the point of a client-side CAPTCHA?!?
The whole purpose of CAPTCHA is to prevent the server from responding to requests that are made by non-humans. What are you trying to achieve?
Spam-bots will not be executing your JavaScript. Humans will. Spam-bots will not get annoyed (even if they could). Humans can, and will.
Client-Side captchas do not provide the protection a server-generated captcha would because the server can not check if the solved captcha is solved correctly.
That is not possible.
You could create something that looks like a CAPTCHA, but it would only run when it's not needed, i.e. when the page is shown in a browser. When it's needed it won't run, as the program trying to break in won't run the client side script.
if your purpose is to simply deflect most bots, you might be able to get away with a simple script that chooses 2 numbers at random and asks user to add them.
Why don't you use reCAPTCHA ? It's free, very efficient, and provides accessibility functionnalities.
I hope I could be of any use. Regards from France ;)
here you are ;)
<html>
<head>
<title>TestPage</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
var captchaText;
$(function() {
var pre = $('#captcha');
captchaText = pre.text();
pre.text('');
var lines = ['', '', '', '', '']
for (var ixLetter = 0; ixLetter < captchaText.length; ixLetter++)
{
var letter = captchaText.substr(ixLetter, 1);
var letterLines = letters[letter];
for (var ix = 0; ix < 5; ix++)
{
lines[ix] = lines[ix] + ' ' + letterLines[ix];
}
}
for (var ix = 0; ix < 5; ix++)
{
pre.append(lines[ix] + '\n');
}
});
function check()
{
if ($('#captchaCheck').val() == captchaText)
{
alert('you are probably human');
}
else
{
alert('you probably made a mistake. Don\'t worry. To err is also human.');
}
}
var letters = {
h: [
'HH HH',
'HH HH',
'HHHHHH',
'HH HH',
'HH HH'
],
i: [
'II',
'II',
'II',
'II',
'II'
]
// etc
}
</script>
</head>
<body>
<pre id="captcha">hi</pre>
Please type what you see: <input id="captchaCheck"/> <input type="button" value="Check" onclick="check()"/>
</body>
</html>