Skip to content

ISO8601 rule (v3)

Validate user input against ISO 8601 Format.

Since
v2.1.0
Signature
ISO8601(input)
Options
0

Usage

ISO8601 usage
bootstrapValidate('#input', 'ISO8601:Your input does not match the wanted format YYYY-MM-DD')

Options

This rule only needs an error message after the rule name, for example ISO8601:Your input does not match the wanted format YYYY-MM-DD.

Live Example

Checking...

Source

ISO8601 source
/**
* @since v2.1.0
* @error Your input does not match the wanted format YYYY-MM-DD
* @description Validate user input against ISO 8601 Format.
*/
export default function ISO8601(input: RuleInput) {
return /^\d{4}-([0]\d|1[0-2])-([0-2]\d|3[01])$/.test(input.value);
}