Thursday, June 5, 2008

JCaptcha Image Changing using Java Script


 

Hi, the last post describe all the steps about JCaptcha implementation.

Now if want to change the Image on click of Captcha image it's very simple. Just replace the code of last post index.jsp with below one.

And the solution work.

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>


 


 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>


<head>


<title>My JSP 'index.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">

    <meta http-equiv="cache-control" content="no-cache">

    <meta http-equiv="expires" content="0">

    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

    <meta http-equiv="description" content="This is my page">

    <!--

    <link rel="stylesheet" type="text/css" href="styles.css">

    -->

<script language="JavaScript" type="text/javascript">


<!--

//function gets the next captcha image


 


function next() {

var now = new Date();


var newSrc = './jcaptcha?' + now.getTime();


if (document.images) {

    document.images.captcha.src = newSrc;


}

}


//-->

</script>


</head>


 


<body>


<form action="./register" method="post">


<a href="javascript:next();">


<img name="captcha" src="./jcaptcha" />


</a>

    <input type='text' name='j_captcha_response' value=''>

    <br/>

    <input type="submit" value="Submit"/>

    

</form>

<br>


</body>

</html>

No comments:

Contributors