# `Bylaw.HTML.Check.RequireButtonType`
[🔗](https://github.com/ryanzidago/bylaw/blob/v0.1.0-alpha.2/lib/bylaw/html/check/require_button_type.ex#L1)

Validates that rendered button tags define a valid `type` attribute.

This check inspects rendered `<button>` elements and flags buttons without a
`type` attribute, or with a `type` value other than `button`, `submit`, or
`reset`.

## Examples

Bad:

    <button phx-click="save">Save</button>

Why this is bad:

Browsers default `<button>` elements to submit buttons, which can submit an
enclosing form when the button was meant to run a local action.

Better:

    <button type="button" phx-click="save">Save</button>

Why this is better:

The button behavior is explicit and does not depend on the browser default.

Bad:

    <button type="save">Save</button>

Why this is bad:

Invalid button types are treated inconsistently by readers and tools.

Better:

    <button type="submit">Save</button>

Why this is better:

The rendered markup uses one of the button types recognized by browsers.

## Options

This check has no check-specific options. Add the module directly to the
explicit checks list:

    Bylaw.HTML.Check.RequireButtonType

## Usage

Add this module to the explicit check list passed through `Bylaw.HTML`.
See `Bylaw.HTML` for the full rendered HTML validation setup.

# `validate`

```elixir
@spec validate(Bylaw.HTML.Check.context()) :: Bylaw.HTML.Check.result()
```

Implements the `Bylaw.HTML.Check` validation callback.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
