0

i'm working on a contact form. i use this for form validation: http://plugins.jquery.com/project/form-validation-and-hints and i use a captcha that stores the code in $_SESSION['captchacode'] variable. what i'm trying to accomplish is to simply check using the jquery validator if user entered good captcha code. that's how check function works:

function isTypeValid( type, value ) {
var cap = <?php echo $SESSION["captchacode"];?>;
if( type == classprefix + 'Text' ) {        
    return true;
}

if( type == classprefix + 'Captcha' ) {
    if(value==cap){
    return (true);
}else{
    return false;
    }
}   

}

i searched a few threads here and elsewhere and that's where i got

    var cap = <?php echo $SESSION["captchacode"];?>;

from.

i've also tried this:

    var cap = "<%= Session['captchacode'] %>";  

and it didn't help... any ideas?

1
  • what's the point in using jquery for captcha valudation? Commented Oct 20, 2011 at 8:52

2 Answers 2

2

Don't use jquery for captcha validation. Validate it on the server side.

also, the way you choose (with writing captcha value in the body of the script) is quite funny but it's merely a gift to possible spammer.

Sign up to request clarification or add additional context in comments.

3 Comments

i want to use jquery because i use it anyway for all the fields validation and it'd be nice to use it also for captcha but i can't manage to validate it from session variable...
beside of "I want" one have to have "I know" and "I understand". And one have to understand that client-side captcha validation can protect NOTHING.
ok that's fair enough:) i'll use a php validation script instead
0

You can use remote method of jquery validation plugin to check captcha. You can see example here -

http://jquery.bassistance.de/validate/demo/captcha

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.