Clearing a form field on page return (html / javascript)

Do you know when you use a password in a field , for example:

<input type="password" name="pass">

And you send a GET or POST to the same page who has the form, and if the user hits back in the browser, the password field becomes empty. Ok, that's fine, but I need to clear another form field when the user hits. Thats because I am asking for a captcha and a text field that store the information entered by the user ramain, populate when he strikes back, but the captcha image changes, and if I am not empty the field, the user (sometimes) does not get what he needs re-enter captcha.

Thanks!

+2


a source to share


2 answers


Try a random input name on every update like:

<input type="text" id="CaptchaTextBox" name="captcha[612361]" />

      

The browser will notice that the input field is different and will clear the value



Edit:

I have a better solution: as the user typed a captcha once, just release it without typing it a second time. Now you know that this user is quite a non-machine, so why does he need to do so much;)

+1


a source


Javascript
window.onload (function ()
{
document.getElementById ("CaptchaTextBox"). Value = '';
});

HTML
<input type = "text" id = "CaptchaTextBox" name = "Captcha" />



Javascript erase textbox value on page load

+1


a source







All Articles