Back button error in Chrome / Safari

I am trying to find a workaround for a button error in Safari / Chrome (the browser puts dummy data in fields where they do not belong). I was not lucky, and it seems that by this time there should be a good solution (I see posts about this, starting in 2009, but without a good solution).

In this example: http://jsfiddle.net/eGutT/13/

you can see that on the initial page load everything is in order. However, by clicking the link, clicking the "Back" button in the browser, the values ​​apply to invalid fields. Please use Safari or Chrome for testing. It works fine on Firefox.

This is a very serious problem, especially when:

  • The user goes to the back button and this error occurs
  • User does not notice dummy data
  • User makes some unrelated form changes (in another unaffected field)
  • User Submits Form

Now you are left with a situation where dummy data is tied to a database!

By the way, this problem may be related to jQuery, since if you uncomment this line in the example:

updateRowNums(); // IF YOU COMMENT OUT THIS LINE... 

no additional / dummy data is entered.

Thanks Galen

+4
source share
1 answer

Are you talking about 0, 1 and 2? Since your function updateRowNums automatically forces these values. If you want to keep this first column, you can change updateRowNums to something like this:

 if (!$('#some_id').val()) { $('#some_id').val(x); } 

(Obviously, this is not the most efficient code, but it resets the field if there is no value.)

However, if this is not what you are talking about, then I could not reproduce your problem. I use Chrome 9.0.597.83 and it has saved all the necessary data in all the necessary places.

0
source

Source: https://habr.com/ru/post/1337515/


All Articles