检查用户是否来自“转发”地址页
我目前正在制作一个发布到网络服务的表单。表单验证是在 Web 服务上完成的,如果发生验证错误,则会向用户显示错误和后退按钮。
该表单包含许多我自动填充的默认值。然后,这些值将覆盖用户按下后退按钮时插入的任何值。
有没有办法可以检测用户是否按下后退按钮并防止自动填充?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜你是通过 JS 填充这些帖子加载的?因为
value
属性不应覆盖新值。如果是的话,我会在加载文本之前检查该字段是否为空。另外,我会研究
placeholder
属性< /a>.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.传递一个参数作为后退按钮将用户发送到的 URL 的一部分,然后检查该参数是否是 Javascript 中当前页面的 URL 的一部分。如果存在,则不填充默认值。
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.