State in the other field is auto-filled when Chrome is used

  • Profile Image
    rsabian
    Asked on December 28, 2016 at 02:03 AM

    2) This is a weird problem.  But when I'm testing out the form if Chrome autofills any part that includes my address at the end of the form it changes the state field at the beginning of my form.

    I sell a different product for each state.  So in the 1st field they choose Alaska.  But at the end of the form, if I fill out the form and chrome puts any Florida information in the address box, then my product changes to Florida with totally different prices.  This ruins the sale.  How do we prevent the browser from changing my first field?

  • Profile Image
    EltonCris
    Answered on December 28, 2016 at 02:25 AM

    I think that's what browser auto-fills do. To prevent it, simply disable the browser auto-fill in your browser. 

    Alternatively, you can embed your form using its source code and add autocomplete="off" in the form tag.

    Example:

    <form method="post" action="/form" autocomplete="off">

    Note that this attribute may not be supported by other browsers so there isn't really a viable solution in all browsers unless the user won't use browser autofill at all.

    In addition, browser autofill usually has the accurate user's data so I don't think this will be a problem at all. Besides users can review their data if they want to. :)

    Thanks!