Minimal Password Strength & Match Validation Plugin For jQuery
File Size: | 4.99 KB |
---|---|
Views Total: | 18428 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |

A lightweight jQuery plugin password validation plugin that validates the strength of a password and provides an instant feedback whether the password meets the requirements you specify.
How to use it:
1. Create two password text fields on the webpage.
<input id="myPassword" type="password"> <input id="myConfirmPassword" type="password">
2. Create an element to place the password requirements.
<div id="errors"></div>
3. Put jQuery library and the jQuery PasswordValidation plugin's script at the bottom of the webpage.
<script src="//code.jquery.com/jquery.min.js"></script> <script src="jquery.password-validation.js"></script>
4. The JavaScript to activate the password validation plugin.
$("#myPassword").passwordValidation({"confirmField": "#myConfirmPassword"}, function(element, valid, match, failedCases) { $("#errors").html("<pre>" + failedCases.join("\n") + "</pre>"); if(valid) $(element).css("border","2px solid green"); if(!valid) $(element).css("border","2px solid red"); if(valid && match) $("#myConfirmPassword").css("border","2px solid green"); if(!valid || !match) $("#myConfirmPassword").css("border","2px solid red"); });
5. Override the default validation rules in the JavaScript.
{ // Minimum Length of password minLength: 12, // Minimum number of Upper Case Letters characters in password minUpperCase: 2, // Minimum number of Lower Case Letters characters in password minLowerCase: 2, // Minimum number of digits characters in password minDigits: 2, // Minimum number of special characters in password minSpecial: 2, // Maximum number of repeated alphanumeric characters in password dhgurAAAfjewd <- 3 A's maxRepeats: 5, // Maximum number of alphanumeric characters from one set back to back maxConsecutive: 3, // Disallow Upper Case Lettera noUpper: false, // Disallow Lower Case Letters noLower: false, // Disallow Digits noDigit: false, // Disallow Special Characters noSpecial: false, // Disallow user to have x number of repeated alphanumeric characters ex.. ..A..a..A.. <- fails if maxRepeats <= 3 CASE INSENSITIVE failRepeats: true, // Disallow user to have x number of consecutive alphanumeric characters from any set ex.. abc <- fails if maxConsecutive <= 3 failConsecutive: true, // selector of confirm field confirmField: undefined };
This awesome jQuery plugin is developed by carreath. For more Advanced Usages, please check the demo page or visit the official website.