views:

82

answers:

3

How can we validate captcha using jquery validation. avoiding post back using ajax? Can anyone please help me on this. Your help would be appreciated.

Thank you.

+1  A: 

You really can't do this, because in most cases the image that gets generated on the server-side stores it's CAPTCHA key in a session, which you cannot access directly from the client side.

I don't even want to think of what could be possible from a security perspective if what your asking actually has a solution other than using Ajax.

Jacob Relkin
Correct me if I am being stupid here, but what's stopping you from sending an ajax request with the captcha key and the user input to the server, and have the server reply with a 'valid' or 'not valid'?
quantumSoup
@Aircule, The OP is asking if it's possible to do this without a postback. Of course it's possible to get a result back from the server saying "valid" or "not valid".
Jacob Relkin
He meant validating the CAPTCHA client side? What sense does that make?
quantumSoup
@Aircule, Tell me about it.
Jacob Relkin
+1  A: 

One of the purposes of the CAPTCHA test is to assess that there is a human sitting at the remote end. If you allow the checking to be done on the client, what's your plan for how the client should tell the server that the verification failed?
How will you prevent that signal from being forged by an attacker?
(Or is it just AJAX you want to replace?)

MattBianco
Thanks you guys for response. Yes I an new to jquery. Yes I wanted to use simple ajax for response in valid or invalid.
Razan
A: 

Hi Razan

If I understand you correctly, you ARE asking for assistance in doing an ajax postback to validate a CAPTCHA test, perhaps just not phrased eloquently.

There is a working example in the jquery docs of how to use remote validation to validate CAPTCHA, this way the validation plugin takes care of not submitting the form if that validation fails and the validation is actually performed on the server. As it should be.

See below:

http://docs.jquery.com/Plugins/Validation#Using_remote_validation_to_help_with_captchas

Hope that helps Razan.

menzies
Thanks menzies. This is exactly what I was looking for. Have you used this example? Could you please tell what do I need to do in file process.php.Thank you.
Razan
Hi Razan. I haven't used the remote plugin to validate a capthca, but in order for the remote validation to work, it must return a true or false value. If you download the .zip archive from here, (http://plugins.jquery.com/project/validate) all the required .php files are in the capthca demo.
menzies