When using the xhtml1-transitional.dtd
doctype, collecting a credit card number with the following HTML
<input type="text" id="cardNumber" name="cardNumber" autocomplete='off'/>
will flag a warning on the W3C validator:
there is no attribute "autocomplete".
Is there a W3C / standards way to disable browser auto-complete on sensitive fields in a form?
No, a good article is here in Mozila Wiki.
I would continue to use the invalid
attribute
. I think this is where pragmatism should win over validating.Valid autocomplete off
HTML 4: No
HTML 5: Yes
Reference: W3
This solution works with me:
if you want use autofill in this region: add
autocomplete="false"
in element ex:How about setting it with JavaScript?
It's not perfect, but your HTML will be valid.