Restricting input characters - mosbymc/validator GitHub Wiki

Input Character Filters

If you would like to restrict the type of characters a user can type into an input, add a data-attribute called "data-inputtype" to the input element. The possible values of data-inputtype are: numeric, integer, positiveInt, nonNumeric, alphaNumeric, printable, printableNonNumeric, phone, shortDate, and longDate. Multiple restriction types can be use in conjunction if delimited by a comma, however when using multiple character restrictions, be careful not to have to opposing restrictions used, like: numeric and nonNumeric.

The validator will listen for the keypress event on that input and restrict or allow each character as it is typed by the user. When multiple values are used, the input character must pass all the restrictions or it will not be printed to the input.

    <input type="text" data-validationrules="zip" data-inputType="alphaNumeric"/>

Input types

numeric: - Any number, decimal, comma, or minus sign is allowed.

integer: - Any number, comma, or minus sign is allowed.

positiveInt: - Any number or comma is allowed.

nonNumeric: - Any non-number is allowed.

alphaNumeric: - All english uppercase and lowercase characters and numbers are allowed.

date: - All numbers, hyphen, decimal, and backslash are allowed.

Continue to: CSS validation classes