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