Skip to content

Latest commit

 

History

History
42 lines (32 loc) · 1.15 KB

autocomplete-valid.md

File metadata and controls

42 lines (32 loc) · 1.15 KB

autocomplete-valid

Ensure the autocomplete attribute is correct and suitable for the form field it is used with.

References

  1. axe-core, autocomplete-valid
  2. HTML 5.2, Autocomplete requirements

Rule details

This rule takes one optional object argument of type object:

{
    "rules": {
        "jsx-a11y/autocomplete-valid": [ 2, {
            "inputComponents": ["Input", "FormField"]
        }],
    }
}

Succeed

<!-- Good: the autocomplete attribute is used according to the HTML specification -->
<input type="text" autocomplete="name" />

<!-- Good: MyInput is not listed in inputComponents -->
<MyInput autocomplete="incorrect" /> 

Fail

<!-- Bad: the autocomplete attribute has an invalid value -->
<input type="text" autocomplete="incorrect" />

<!-- Bad: the autocomplete attribute is on an inappropriate input element -->
<input type="email" autocomplete="url" />

<!-- Bad: MyInput is listed in inputComponents -->
<MyInput autocomplete="incorrect" />