Jump to content


Photo

Reloading Verification Image


  • Please log in to reply
1 reply to this topic

#1 bachya

bachya
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 12 July 2006 - 07:02 PM

Hi all,

I have a form that uses CAPTCHA as a means of verification that the submitter is not spambot, or anything similar.  I have a button next to the place where the user is supposed to input the letters/numbers in the image:

<button onclick="NewVerifyImage();">New image</button>

...and the NewVerifyImage() function looks like this:

<script language="javascript" type="text/javascript">
var nReload = 5;

function NewVerifyImage()
{
    if (nReload <= 2)
        if (nReload <= 0)
        {
            alert("Sorry, too many reloads.");
            return;
        }
        else
            alert("Only " + nReload + " more reloads are allowed");
    nReload--;
    document.vimg.src = "verifyimg.php";

}
// -->
</script>

This calls a script called verifyimg.php, which would generate a new CAPTCHA image and place it in the image called "vimg" - however, when I click this "New Image" button, it's as though I've clicked submit - the form goes to the page I redirect the user to when info has been submitted.

Does anyone have any idea why it seems like this button is not calling the function properly?

Thanks!

#2 bachya

bachya
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 13 July 2006 - 02:55 PM

Never mind - figured out that I needed to add a "return false;" so that the script wouldn't move past that button. :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users