Refresh Simple Captcha

I am using simple captcha in my JSP. Everything is OK. I want to provide a refresh button alongside of captcha to allow user to change the captcha. Captcha changes only on refreshing the complete page but I don't want to reload whole page for it.

I need your suggestions on how I can implement this like using AJAX or JQuery to reload only the captcha, not whole page.

-------------Problems Reply------------

<script type="text/javascript">
function reloadCaptcha(){
var d = new Date();
$("#captcha_image").attr("src", "/captcha_generator.jsp?"+d.getTime());
}
</script>
...
<img id="captcha_image" src="/captcha_generator.jsp" alt="captcha image" width="200" height="50"/>
<img src="reload.jpg" onclick="reloadCaptcha()" alt="reload"width="40" height="40"/>

I don't remember how SimpleCaptcha works, but usually, you should simply change the 'src' attribute of you captcha <img>. Something like this on the onClick of your refresh button:

var img = document.getElementById('captcha_id');// captcha_id is the id attribute of your caprtcha img
img.src = 'Some new captcha url';

<script type="text/javascript">
function reloadCaptcha(){
var d = new Date();
$("#captcha_image").attr("src", "captcha.php?"+d.getTime());
} </script>

<img id="captcha_image" src="captcha.php" alt="captcha image" width="90" height="33"/> <img src="images/refresh.png" alt="reload" width="22" height="22" border="0" onclick="reloadCaptcha()" />

Category:java Views:1 Time:2012-04-14

Related post

  • Problems With Simple captcha 2010-09-10

    I have a weird issue .I am using simple captcha in forms in my rails applications. If I am using one captcha in a web page I don't have any problem. But I have a scenario of using three(3) forms in one page in which all the three forms will have the

  • Breaking a simple Captcha 2010-05-26

    For testing purpose, I need to break this captcha: http://wapforum.us/web/img.php As you can see, this is a very simple captcha with only 4 digits of numbers. Any sample code will be highly appreciated. Thanks and Regards, Masnun --------------Soluti

  • django: Adding simple captcha to django comments 2010-10-05

    I am trying to understand how it's possible to use http://code.google.com/p/django-simple-captcha/ with django comments. I have done all as described here: http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/ So my forms in custom commen

  • how to integrate a simple captcha with devise at registration in rails 3? 2011-08-25

    Please tell me how can i integrate simple captcha with devise. How can i use simple_captcha_valid? for captcha authentication in devise registration cont Is there any way i can do custom validation for the authentication of captcha because i cannot m

  • Django - problem with django-simple-captcha 2011-08-27

    I have an issue about http://code.google.com/p/django-simple-captcha/ project. I've follow the procedure to install captcha, the form works but the browser don't load the image. What to do? My patterns: from django.conf.urls.defaults import patterns,

  • simple captcha instllation problems on rails 3.1.3 2011-12-26

    I have installed SimpleCaptcha plugin to vendor/plugin For the setup the plugin I am getting rake simple_captcha:setup Gives me error: rake aborted! Don't know how to build task 'simple_captcha:setup' I checked rails version by gem list rails (3.1.3)

  • [PHP/JavaScript]: How to refresh a Captcha? 2009-10-27

    I am showing Captcha in this way: <img src="ReturnCaptcha2.php" alt="CAPTCHA" width="100" height="50"> I have a hyperlink named "Reload" near it. I want to recall that PHP file without refreshing my page. Probably, AJAX is involved in it. Pleas

  • Use jQuery's ajax call to refresh a captcha 2010-08-16

    I wrote my own php captcha script, with a jpeg header, so that I can say <img src="captcha.php"> which works by storing the value of the captcha into the session variable. When the user can't read it, I want it to be refreshable. I first tried

  • What's wrong with my simple captcha php script? 2011-05-31

    I also have session_start(); at the top of my index page, its not working! <?php if(isset($_REQUEST['Submit'])){ $key=substr($_SESSION['key'],0,5); $captcha = $_REQUEST['captcha']; if($captcha=!$key){ exit(); } $EmailFrom = "****"; $EmailTo = "***

  • Simple Captcha Session Issue 2011-08-03

    I've got a quite ridiculous problem with a captcha image and session variable. http://paholo.com/npdev/tests/contact_us2.php?add=1&confirm=new#contact I've used this same "Contact us" script numerous other times but clearly something is now off w

  • Where to put Java Simple Captcha Builder? 2010-01-14

    I am a newbie at java/java servlet. I need the simpleCaptcha for a form, using html and javaservlet for the code. With reference to http://simplecaptcha.sourceforge.net/extending.html. Captcha captcha = new Captcha.Builder(200, 50) .addText() .addBac

  • Simple Captcha and make different colors 2011-07-01

    I've just watched the link as http://simplecaptcha.sourceforge.net/ and it gives demo of some images showing that captcha can be designed as a colored one so it can be not only black and white one. But for some reason I couldn't find any tutorials of

  • im not sure where im going wrong the form is a simple captcha but it does not validate the first condition in my if statement 2013-12-06

    this is the first php script that would get saved as image.php. this is the code: <?php $img = imagecreatetruecolor(200,80); $white = imagecolorallocate($img, 255, 255, 255); $black = imagecolorallocate($img, 0, 0, 0); $red = imagecolorallocate($i

  • jQuery Simple Captcha Plugin 2010-05-19

    I am using the jQuery SimpleCaptcha plugin - it loads the images fine - but you are unable to click on them. Can anyone give me any hints? <html> <head> <script type='text/javascript' src='jquery-1.4.2.min.js'></script> <sc

  • How to refresh captcha image on page refresh/load? 2011-05-29

    I want to force my site to refresh the captcha image everytime it loads, so I have a javascript method triggered with the onload() event. Here I have the following line: document.getElementById('yw0_button').click; Firebug doesn't detect any errors,

  • Captcha code refresh problem 2011-03-13

    I've a quick contact form on every page of my site. For captcha code I'm using free php catcha code generation script in img tag. Quick contact form is a separate form which I included in other pages. I tried jQuery $.ajax() function to refresh the c

  • Java How to refresh Captcha in jsp genertaed through Servlet class 2014-12-04

    I am trying to refresh captcha image through jquery in jsp page but its not working and the captcha image is generated through java servlet class . Please how I can refresh the captcha image without refreshing whole page. Here is my servlet code publ

  • Need a jQuery captcha solution for my registration form 2011-04-04

    I have a registration form that I validate with jQuery. If there are errors, it says so without page refresh. What I'm trying to do is to implement a captcha that doesn't require a page refresh to work. I tried implementing Google's reCaptcha but doi

  • Breaking CAPTCHAs for a Noble Purpose 2009-11-17

    CAPTCHAs that ask users to read distorted text are fine for sighted people, but a terrible barrier for those who are blind or have other disabilities. Audio alternatives are occasionally available but still don't help those who are both deaf and blin

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.155 (s). 11 q(s)