Data validation checks if data is reasonable, but cannot check if it is correct.
There are eight types of input validation you need to know.
Data Type Check
Ensures data is of a specific type (e.g. an integer).
Example: A year must only contain an integer (e.g. 1975).
Format Check
Data must match a specific combination of character types.
Example: A national insurance number must be in the NN LL LL LL N (where N is a number and L is a letter) format (e.g. CR 83 92 10 Z).
Input Mask
Spaces are provided for specific characters to be entered.
Example: A Credit card input field would be split into four blocks of four numbers (e.g. 0000 0000 0000 0000).
Length Check
There is a minimum and/or maximum number of characters required.
Example: A password must be at least 10 characters.
Limited choice
Data can only be selected from pre-defined options (users cannot type their own data).
Example: An online clothes shop only allows users to select "S", "M", "L", or "XL".
Lookup
A check that what the user enters exactly matches one in an existing list.
Example: Typing a product stock code into a database and comparing it to an existing product code.
Presence Check
Checking if an input box has something entered into it.
Example: The "Full Name" field must not be empty; leaving it blank produces an on-screen alert.
Range Check
Checking if a value is between two numbers.
Age entry requires a value between 11 and 18; entering "9" or "21" triggers a warning.