Search code examples
javascriptjquerybrowserback

Check to see if a user has came from a 'forward' page


I am currently working on a form which posts to a web service. The form validation is done at the web service and if a validation error occurs the user is presented with an error and a back button.

The form contains a number of default values which I am auto populating. These values then overwrite any values that the user has inserted when the back button is pressed.

Is there a way I can detect to see if the user has pressed the back button and prevent the auto population?


Solution

  • My guess would be you are filling these post load via JS? Because the value attribute should not override new values. If you are, I would just do a check to see if the field is empty before loading in the text.

    Also, I would look into the placeholder attribute.