views:

156

answers:

3

i have a form with a capacha, if the capacha was entered wrong, after submit the page is doing a "history.go(-1)" and all fields include the capacha input are back on the screen

right now i have a js that clear that - but now that i need it in several places, i want to know if it possible to clear a form field after back with something related to the html form or what ever

thanks

A: 

I think it's a bad idea to use "history.go(-1)" and JavaScript at all. You must validate captcha on the server side and in server side choice that page you must render? again with captcha or next.

Falcon
the Capacha is server side, but when finished with error it send back with history.back - it is a code from the internet that my boss got for 45$
Y.G.J
Ok. if captcha is serverside. Why you can't rerander captcha page if captcha is wrong?
Falcon
because i send the page trought a form on a page that rebuilding it from querystring will talk more work
Y.G.J
+1  A: 

Have you tried looking into cache controlling the CAPTCHA image (or the page that loads it up)?

pinkgothic
A: 

I dont think its possible with only html, need to add some programming.

You can have js function that is called on onload event of document.

function can be like this:

function resetfields()
{
  $("input[type=text]").val("");
  $("textarea").val(""); // if any textarea
}

And you can also use some ajax in this function to get a new captcha every time.

you can place this function in your master/header page, so that you don't need to copy it to all pages (for that you may need to make selector more precise).

Ashish Rajan