简体   繁体   中英

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?

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 .

Pass a parameter as part of the URL that your back button sends the user to, then check to see if that parameter is part of the URL of the current page in your Javascript. If it's present simply don't populate with the default values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM