I’ve solved this unwanted behaviour by adding
autocomplete="off" to that hidden input, but W3Cdoesn’t like this solution, and if i validate the page I get the error:
Attribute autocomplete not allowed on element input at this point.
autocomplete attribute works only on specific inputs – see here.
So is there any solution that will satisfy both W3C and Firefox?
To validate (which I wouldn’t put as much effort into as you are) I think you could use
autocomplete="off" on the entire form, then turn it back on selectively, like this:
<!DOCTYPE html> <html> <head> <title>TEST</title> </head> <body> <form autocomplete="off"> <input type="hidden" name="test"> <input type="text" name="otherfield" autocomplete="on"> </form> </body> </html>
I initially thought this was a Firefox bug but after discussion with robertc in the comments, I think expected behavior depends on specific use cases. The spec doesn’t allow autocompletion on hidden fields so my first reaction still feels right, but Firefox’s implementation might have some good arguments to support it. Please comment.