acknowledgments update
[openemr.git] / interface / usergroup / checkpwd_validation.js
blob90fec80a284a47bd29fc6e2779da3b917030c663
1 //-------------------------------------------------------------------
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
6 //Author:- Author:- ViCarePlus Team, Visolve
7 //Email ID:- vicareplus_engg@visolve.com
8 //-------------------------------------------------------------------
11 /* 
12  *  Fuction to check that the password contains at least 3 of the following:
13  *  - an integer one integer
14  *  - a lower case letter
15  *  - an upper case letter
16  *  - a special character
17  *  Also, the password should be at least 8 characters.
18  */
19 function passwordvalidate(password_string) {
20     var pwd = password_string;
21     var items = 0;
22     if (pwd.length < 8) {
23         return false;
24     }
25     var rgx = /[a-z]+/;
26     if (rgx.test(pwd)) {
27         items += 1;
28     }
29     rgx = /[A-Z]+/;
30     if (rgx.test(pwd)) {
31         items += 1;
32     }
33     rgx = /\d+/;
34     if (rgx.test(pwd)) {
35         items += 1;
36     }
37     rgx = /[\W_]+/;
38     if (rgx.test(pwd)) {
39         items += 1;
40     }
41     if (items < 3) {
42         return false;
43     }
44     return true;
47 // Removes leading whitespaces
48 function LTrim(value) {
49     var re = /\s*((\S+\s*)*)/;
50     return value.replace(re, "$1");
53 // Removes ending whitespaces
54 function RTrim(value) {
55     var re = /((\s*\S+)*)\s*/;
56     return value.replace(re, "$1");
59 // Removes leading and ending whitespaces
60 function trim(value) {
61     return LTrim(RTrim(value));