Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/availity/textcomplies
JQuery plugin that checks text input against a set of rules you specify and provides feedback in real time.
https://github.com/availity/textcomplies
Last synced: about 14 hours ago
JSON representation
JQuery plugin that checks text input against a set of rules you specify and provides feedback in real time.
- Host: GitHub
- URL: https://github.com/availity/textcomplies
- Owner: Availity
- License: mit
- Created: 2011-06-08T19:15:07.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2024-10-01T18:50:16.000Z (3 months ago)
- Last Synced: 2024-11-11T21:34:16.796Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 62.5 KB
- Stars: 2
- Watchers: 42
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Text Complies
A jQuery plugin that checks text input against a set of rules you specify and provides feedback in real time.
## Description
With the Text Complies plugin, you can specify a set of rules that the input for a specified text field must comply with. As the user types in the field you're checking, the compliance level to the rules is updated, and you can report to the user which rules they're complying with and which rules they're defying.
A typical usage for this plugin is with passwords; you can provide a set of rules (e.g., password must be 8-12 characters, contain one letter and one number, and can't contain spaces), and this plugin list the rules and whether or not the password the user is typing complies with those rules. As the user types the password, this plugin updates the compliance to the rules.
## Options
Text Complies allows you to configure several preset rules for compliance checking, each with accompanying text that you can override. Rules you don't configure are not invoked. Your options are:
* `minLength`: the minimum allowable length of the text
* `minLengthText`: the custom text to use for the minimum length rule
* `maxLength`: the maximum allowable length of the text
* `maxLengthText`: the custom text to use for the maximum length rule
* `minAndMaxLengthText`: the custom text to use when you specify both a minimum length and maximum length
* `showNumbersAsWords`: whether to show numbers less than 10 as words
* `numNumbers`: the minimum number of numbers (digits) the text must contain
* `numNumbersText`: the custom text to use for the number of numbers rule
* `numUppercaseLetters`: the minimum number of uppercase letters the text must contain
* `numUppercaseLettersText`: the custom text to use for the uppercase rule
* `numLowercaseLetters`: the minimum number of lowercase letters the text must contain
* `numLowercaseLettersText`: the custom text to use for the lowercase rule
* `numLetters`: the minimum number of letters the text must contain
* `numLettersText`: the custom text to use for the number of letters rule
* `disallowed`: an array containing strings that the text can't contain
* `disallowedText`: the custom text to use for the disallowed rule
* `matchField`: the selector of a text field whose value must match the text
* `matchFieldText`: the custom text to use for the match field rule
* `matchPattern`: the regular expression that the text must match
* `matchPatternCaseSensitive`: whether the regular expression is case sensitive
* `matchPatternText`: the custom text to use for the match pattern rule
* `disallowedPattern`: the regular expression that the text can't match
* `disallowedPatternCaseSensitive`: whether the regular expression is case sensitive
* `disallowedPatternText`: the custom text to use for the disallowed pattern rule
* `validateOnStart`: whether to validate the rules on start
* `showAsFailOnStart`: whether to show all the rules as failing on start
* `output`: the selector of an HTML element in which to display the output of the rules
* `onComplies`: a JavaScript method called if the text complies with all the configured rules
* `onDefies`: a JavaScript method called if the text doesn't comply with any of the configured rules## Usage
The compliance goes here
$('#password').textComplies({
output: $('#password_compliance'),
minLength: 3,
maxLength: 12,
disallowed: [ ' ', '$', 'password' ],
matchField: $('#password_match'),
onComplies: passwordComplies,
onDefies: passwordDefies
});function passwordComplies() {
$('#myButton').removeAttr('disabled');
}function passwordDefies() {
$('#myButton').attr('disabled', 'disabled');
}
.complies {
background-color: green;
}.defies {
background-color: red;
}#password_compliance {
border: 1px solid black;
}
## Links
* Author: [Rob Warner](http://github.com/hoop33)
* Company: [Availity, LLC](http://www.availity.com)
* License: [MIT](http://www.opensource.org/licenses/mit-license.php)