FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

10 snippets foundClear filters
HTMLInput constraints

Allow several selected options

HTML: A multiple select exposes each selected option as a value with the same control name.

HTML✓ Tested
HTMLInput constraints

Constrain a calendar date input

HTML: Use ISO date values for the date control’s minimum and maximum.

HTML✓ Tested
HTMLInput constraints

Limit a numeric input to an inclusive range

HTML: Number inputs expose range validation separately from the entered text.

HTML✓ Tested
HTMLInput constraints

Limit typed text to a maximum length

HTML: Maxlength limits ordinary user editing without replacing server-side validation.

HTML✓ Tested
HTMLInput constraints

Require a checkbox to be selected

HTML: A required checkbox is invalid until that individual control is checked.

HTML✓ Tested
HTMLInput constraints

Require a nonempty text value

HTML: The required attribute makes an empty text control fail native constraint validation.

HTML✓ Tested
HTMLInput constraints

Require numeric values on a chosen step

HTML: The step interval is measured from the minimum value when one is provided.

HTML✓ Tested
HTMLInput constraints

Select a time in quarter-hour increments

HTML: A time step is expressed in seconds, so 900 represents fifteen minutes.

HTML✓ Tested
HTMLInput constraints

Validate a structured text identifier

HTML: The pattern attribute matches the entire nonempty input; required handles the empty case.

HTML✓ Tested
HTMLInput constraints

Validate the shape of an absolute URL

HTML: A URL input checks syntax, not whether a resource exists or is safe.

HTML✓ Tested