Skip to content

Rules (v2)

Use these rules as the second argument to bootstrapValidate(). Empty optional fields pass non-required rules in v2.3.0 and later.

min

Require a given minimum character count.

Since 1.0.0 1 option

min
bootstrapValidate('#input', 'min:20:Enter at least 20 characters!')

Open rule reference

max

Maximum character count required.

Since 1.0.0 1 option

max
bootstrapValidate('#input', 'max:42:Please dont enter more than 42 characters!')

Open rule reference

email

Require a valid E-Mail Address.

Since 1.0.3 0 options

email
bootstrapValidate('#input', 'email:Enter a valid email address')

Open rule reference

required

Require a field to be filled out.

Since 1.0.7 0 options

required
bootstrapValidate('#input', 'required:Please fill out this field!')

Open rule reference

url

Require a valid URL.

Since 1.0.10 0 options

url
bootstrapValidate('#input', 'url:Please enter a valid URL!')

Open rule reference

integer

Require a valid integer.

Since 1.0.10 0 options

integer
bootstrapValidate('#input', 'integer:Please fill out this input field!')

Open rule reference

numeric

Require a valid numeric input.

Since 1.0.10 0 options

numeric
bootstrapValidate('#input', 'numeric:Please only enter numeric characters!')

Open rule reference

alphanum

Require alphanumeric input, e.g. 0-9 and a-Z.

Since 1.0.10 0 options

alphanum
bootstrapValidate('#input', 'alphanum:Please only enter alphanumeric characters!')

Open rule reference

ISO8601

Validate user input against ISO 8601 Format.

Since v2.1.0 0 options

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

Open rule reference

regex

Test a Regular Expression against an input value

Since v2.1.0 1 option

regex
bootstrapValidate('#input', 'regex:^[a-z]+$:Please fulfill my regex')

Open rule reference

divisible

Test if input number can be divided by given number and the result is an exact whole number.

Since v2.1.0 1 option

divisible
bootstrapValidate('#input', 'divisible:15:15 is not divisible by 4.')

Open rule reference

contains

Require the input to contain a given string.

Since 1.0.11 1 option

contains
bootstrapValidate('#input', 'contains:something:Your text needs to contain something!')

Open rule reference

startsWith

Require the input value to start with a given string.

Since 1.1.0 1 option

startsWith
bootstrapValidate('#input', 'startsWith:+49:Your phone number needs to start with +49')

Open rule reference

endsWith

Require the input value to end with a given string.

Since 1.1.0 1 option

endsWith
bootstrapValidate('#input', 'endsWith:UCV:Your Input needs to end with UCV')

Open rule reference

matches

Require the input value to match the given inputs value. Like bootstrapValidate's first Parameter, you can pass a selector or Element.

Since 1.1.0 1 option

matches
bootstrapValidate('#input', 'matches:#passwordConfirm:Your passwords should match')

Open rule reference

alpha

Validate only alphabetic characters - a-z, A-Z.

Since 1.1.0 0 options

alpha
bootstrapValidate('#input', 'alpha:You can only input alphabetic characters')

Open rule reference

inArray

Validate if user input is in given array. Similar to contains, but with an array.

Since 2.2.0 1 option

inArray
bootstrapValidate('#input', 'inArray:(ABC, DEF, GHI):Your input must be any of (ABC, DEF, GHI)')

Open rule reference

requiredUnless

Require a field unless another field already has a value.

Since 2.3.0 1 option

requiredUnless
bootstrapValidate('#input', 'requiredUnless:#secondaryEmail:Enter at least one email address')

Open rule reference

text

Require Latin letters, accented Latin letters, spaces, apostrophes, and hyphens.

Since 2.3.0 0 options

text
bootstrapValidate('#input', 'text:Enter letters only')

Open rule reference

between

Require a numeric value between two inclusive bounds.

Since 2.3.0 2 options

between
bootstrapValidate('#input', 'between:18:65:Enter a number between 18 and 65')

Open rule reference