File tree Expand file tree Collapse file tree 5 files changed +24
-9
lines changed
Expand file tree Collapse file tree 5 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 44
55- Thai localization.
66- Fix typo in German localization.
7+ - Activate by default the extra security rules.
8+ - Make the invalid chars optional rule configurable.
79
810## 2.1.3
911
Original file line number Diff line number Diff line change @@ -34,6 +34,13 @@ Let's see the options of each section.
3434 The username field to match a password to, to ensure the user does not use
3535 the same value for their password.
3636
37+ * __ invalidCharsRegExp__ :
38+
39+ Default: ` new RegExp(/[\s,'"]/) ` (Regular Expression)
40+
41+ A regular expression object to use to test for banned characters in the
42+ password.
43+
3744* __ userInputs__ :
3845
3946 Default: ` [] ` (Array)
Original file line number Diff line number Diff line change @@ -174,20 +174,25 @@ $(document).ready(function () {
174174```
175175
176176
177- ## Extra security
177+ ## Extra restrictions
178178
179179The plugin comes with two validation rules deactivated by default. One checks
180- for too many character repetitions, and the other checks the number of
181- character classes used. An easy way to increase the security of the passwords
182- is to activate this two rules:
180+ the length of the password and penalizes it if it's too long; and the other
181+ checks if the password contains a banned char, and penalizes it if it does.
182+
183+ You can configure the max length of the password by using the option ` maxChar ` .
184+ You can also configure the invalid chars by using the option
185+ ` invalidCharsRegExp ` .
186+
187+ If you need these restrictions you just need to activate this two rules:
183188
184189``` javascript
185190$ (document ).ready (function () {
186191 var options = {};
187192 options .rules = {
188193 activated: {
189- wordTwoCharacterClasses : true ,
190- wordRepetitions : true
194+ wordMaxLength : true ,
195+ wordInvalidChar : true
191196 }
192197 };
193198 $ (' :password' ).pwstrength (options);
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ defaultOptions.common = {};
1515defaultOptions . common . minChar = 6 ;
1616defaultOptions . common . maxChar = 20 ;
1717defaultOptions . common . usernameField = "#username" ;
18+ defaultOptions . common . invalidCharsRegExp = new RegExp ( / [ \s , ' " ] / ) ;
1819defaultOptions . common . userInputs = [
1920 // Selectors for input fields with user input
2021] ;
@@ -56,8 +57,8 @@ defaultOptions.rules.activated = {
5657 wordInvalidChar : false ,
5758 wordSimilarToUsername : true ,
5859 wordSequences : true ,
59- wordTwoCharacterClasses : false ,
60- wordRepetitions : false ,
60+ wordTwoCharacterClasses : true ,
61+ wordRepetitions : true ,
6162 wordLowercase : true ,
6263 wordUppercase : true ,
6364 wordOneNumber : true ,
Original file line number Diff line number Diff line change 5454 } ;
5555
5656 validation . wordInvalidChar = function ( options , word , score ) {
57- if ( word . match ( / [ \s , ' , " ] / ) ) {
57+ if ( options . common . invalidCharsRegExp . test ( word ) ) {
5858 return score ;
5959 }
6060 return 0 ;
You can’t perform that action at this time.
0 commit comments