0

I have a series of textfields and textboxes that a user can fill out, then click send. If he hits the back button, I want those fields to be empty. Currently, when the user clicks back, those fields are filled with data entered before the submit.

Is there a solution for this that works in (almost) all browsers?

Derek
  • 9,773
  • 7
  • 29
  • 34
  • Here is a similar tread: http://stackoverflow.com/questions/158319/cross-browser-onload-event-and-the-back-button – Endre Simo Aug 13 '12 at 19:31

1 Answers1

1

On the load of the page, iterate over all the inputs and set their value to an empty string. Though, really, is there a good reason to do that to your users? That's more of a browser feature for their convenience than a site feature.

$('input[type=text]').each(function(input){
    input.value="";
});
FrankieTheKneeMan
  • 6,645
  • 2
  • 26
  • 37
  • Thanks! As to why... it's a long story but do trust it is to avoid a lot of user frustration :) – Derek Aug 13 '12 at 20:33
  • I've read that there is no "onload" event for a page loaded, I suspect because the page isn't loaded. You may want to use the unload() event in jquery. – FrankieTheKneeMan Aug 13 '12 at 20:35