Validator Demo

Validator has been applied to this form to help sanitize and validate user input.
This form won't submit if any fields are invalid and helpful errors will be shown or hidden as the user changes fields.

Install this Validator through npm:
npm install @jdlien/validator

Source code and documentation at github.com/jdlien/validator.

Fields can be required, have a minimum or maximum length, or a pattern.
Numeric inputs won't even allow invalid values to be typed in.

A letter followed by numbers (^[a-zA-Z]\d+$)

Up/down arrow keys increment & decrement

Negative numbers and decimals are allowed

Dates can be entered by users in almost any format, and will be converted to the format specified in the data-date-format attribute.
Dates can also be constrained to past or future dates.
These features are compatible with datepickers like Flatpickr.

Any date will be converted to the YYYY-MMM-DD format

YYYY-MM-DD format is enforced

Datetime can be used to also include a time with a date

Datetime can be used to also include a time with a date

This is a text input with a provided error

A North-American phone number will be formatted on change

Anything resembling a time will be converted into the specified format

The label will show a swatch of any valid color

Selects can be required as well.

You can require groups of radio buttons or checkboxes so one must be selected.

Textarea elements can have min and max lengths as well as be required.

If the form is invalid when submitted, 'form-error-main' will be displayed above.