API and quick reference - mosbymc/validator GitHub Wiki
##Public functions validator.setAdditionalEvents() - Adding new event listeners
validator.removeErrors() - Removing error message programmatically
validator.validate() - Public validation hook
Data-Attributes:
data-required: Returns true if the field is a non-empty string for drop-downs and text inputs. Returns true if a value has been selected for radio button groups.
data-min: Returns true if the minimum value specified by the attribute is met.
data-max: Returns true if the maximum value specified by the attribute is not exceeded.
data-minchecked: Returns true if at least n number of options are selected, as specified in the attribute. Each checkbox in the group requires an attribute called "data-checkboxgroup" with the shared value.
data-maxchecked: Returns true if no more than n number of options are selected as specified in the attribute. Each checkbox in the group requires an attribute called "data-checkboxgroup" with the shared value.
data-matchfield: Returns true if the input has the same value as another input. The other input's id should be the value of the attribute.
data-validationrules values:
email: Returns true if the string entered has the general structure of an email.
ssn: Returns true if the field contains only numbers and hyphens and has the same format as a nine digit social security number.
uscurrency: Returns true if the field contains only digits, decimals, commas, or the '$' symbol. While the '$' symbol, decimals, and commas are optional, they must be in the appropriate places.
phone: Returns true if the field contains ten digits with each section of the phone number separated by "()", "- ", or " ".
numeric: Returns true if all characters in the input are numeric only.
zip: Returns true if there are five digits in the input.
date: Returns true if value is a date comprised only of digits - American or European formats both accepted.
url: Returns true if the value has the same structure as a basic url.
password: Returns true if value has at least one uppercase letter, one lower case letter, and one digit, and is a minimum of eight characters.
####Input types for character restriction 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.
####CSS Classes .validate - Used on submit buttons for form validation. Needed for the validator to actual validate the form when the button is clicked.
.alignInput - Used by the validator when the "groupByInput" class has been used to grouping the error messages at the input level.
.errorMessage - Used by the validator on the basic fixed postioned error message divs.
.hideMessage - Used for hiding all fixed error containers - help text and basic error message divs.
.showMessage - Reverse of the .hideMessage class.
.hideGroupedErrors - This style is used by the validator when when the "data-grouperrors" attribute has been used to group the error messages at the form level. It should initially be added by the developer on the div container where the error messages will be added.
.showGroupedErrors - Reverse of the .hideGroupedErrors class.
.groupHighlight - Used to highlight error messages that are associated with whichever input the mouse is currently hovering over when they are grouped at the form level.
.inputGroup - Used to style the error message div when the "groupByInput" class has been used to group error messages at the input level.
.errorSpan - Used to wrap individual error messages when grouped by form.
.inputGrpErrorSpan - Used to wrap individual error messages when grouped by input.
.invalid - Put on the inputs that failed validation.
.helpText - Used to denote/style help text containers. Should be place by the developer.