PageSourceSearch

https://payatlwateronline.com/capricorn/js/jquery.validate-v1.13.1/jquery.validate.password.js

js payatlwateronline.com collected 2026-10-08 09:40:00 UTC 4,466 bytes, 142 lines download raw bytes

1/*
2 * jQuery validate.password plugin - custom version base on version 1.0
3 *
4 * http://bassistance.de/jquery-plugins/jquery-plugin-validate.password/
5 *
6 * Copyright (c) 2009 Jörn Zaefferer
7 *
8 * $Id: jquery.validate.password.js,v 1.1 2012/11/06 14:50:30 wtse Exp $
9 *
10 * Dual licensed under the MIT and GPL licenses:
11 *   http://www.opensource.org/licenses/mit-license.php
12 *   http://www.gnu.org/licenses/gpl.html
13 */
14(function($) {
15	
16	var LOWER = /[a-z]/,
17		UPPER = /[A-Z]/,
18		DIGIT = /[0-9]/,
19		DIGITS = /[0-9].*[0-9]/,
20		SPECIAL = /[^a-zA-Z0-9]/,
21		SAME = /^(.)\1+$/,
22		VALID_CHARS = /^[0-9a-zA-Z!?$%&\^*()_\+:@~#|,.]+$/;
23		
24	function rating(rate, message) {
25		//parent.document.forms[0].passwordStrengthRate.value = rate;
26		//parent.document.getElementById("passwordStrengthRate").value = rate;
27		document.getElementById("passwordStrengthRate").value = rate;
28		return {
29			rate: rate,
30			messageKey: message
31		};
32	}
33	
34	function uncapitalize(str) {
35		return str.substring(0, 1).toLowerCase() + str.substring(1);
36	}
37	
38	$.validator.passwordRating = function(password, username, minRating) {
39		if (!password) 
40			return rating(10, "Password-not-required");
41			//return rating(0, "Password-required");
42		if (!VALID_CHARS.test(password))
43			return rating(2, "invalid-character");		
44		if (password.length < 8)
45			return rating(0, "too-short");
46		if (password.length > 20)
47			return rating(0, "too-long");
48		if (username && password.toLowerCase() == (username.toLowerCase()))
49			return rating(0, "similar-to-username");
50		if (SAME.test(password))
51			return rating(1, "very-weak");
52		
53		var lower = LOWER.test(password),
54			//upper = UPPER.test(uncapitalize(password)), why upcaptilize the first character?
55			upper = UPPER.test(password),
56			digit = DIGIT.test(password),
57			digits = DIGITS.test(password),
58			special = SPECIAL.test(password);
59		
60		// 2015-10-30 : change the strength level.
61		// meet 3 out of 4 requirements = strong.
62		var meetNumOfRequirements = 0;
63		if(lower)
64			meetNumOfRequirements += 1;
65		
66		if(upper)
67			meetNumOfRequirements += 1;
68		
69		if(digit)
70			meetNumOfRequirements += 1;
71		
72		if(special)
73			meetNumOfRequirements += 1;
74		
75		/* Strong (or restricted) validation rules */
76		if(minRating >= 5){
77			if(meetNumOfRequirements >= 4){
78				return rating(5, "strong");
79			}else if(meetNumOfRequirements == 3){
80				return rating(4, "not-good-enough");
81			}else{
82				return rating(3, "weak");
83			}
84		}
85		
86		/* eash-going rules for Better User Experience */
87		else{
88			// Strong: contains Upper letter/Lower letter, numbers, sepcial characters.
89			if (meetNumOfRequirements>=3) 
90				return rating(5, "strong");
91			
92			// Fair: meet at least 2 of the following 3 rules: letter, number, sepcial characters.
93			else if (lower && digit || upper && digit || (special && (lower||digit||upper)) )
94				return rating(4, "fair");
95			
96			else
97				return rating(3, "weak");
98		}
99	}
100	
101	$.validator.passwordRating.messages = {
102		"Password-not-required" : "",
103		"Password-required" : "Password required",
104		"similar-to-username": "Password too similar to username",
105		"too-short": "Password too short",
106		"too-long": "Password too long",
107		"very-weak": "Very weak password",
108		"weak": "Weak password",
109		"fair": "Fair password",
110		"not-good-enough": "Not good enough",
111		"strong": "Strong password",
112		"invalid-character": "Invalid Character Entered"
113	}
114	
115	$.validator.addMethod("check_password", function(value, element, params) {
116		var usernameField = params.usernameField;
117		var minRating = params.minRating;
118		
119		// use untrimmed value
120		var password = element.value,
121		// get username for comparison, if specified
122			username = $(typeof usernameField != "boolean" ? usernameField : []);
123			
124		var rating = $.validator.passwordRating(password, username.val(), minRating);
125		// update message for this field
126		
127		var meter = $(".password-meter", element.form);
128		
129		meter.find(".password-meter-bar").removeClass().addClass("password-meter-bar").addClass("password-meter-" + rating.messageKey);
130		meter.find(".password-meter-message")
131		.removeClass()
132		.addClass("password-meter-message")
133		.addClass("password-meter-message-" + rating.messageKey)
134		.text($.validator.passwordRating.messages[rating.messageKey]);
135		// display process bar instead of error message
136		
137		return rating.rate >= minRating;
138	}, "&nbsp;");
139	// manually add class rule, to make username param optional
140	$.validator.classRuleSettings.password = { check_password: true };
141	
142})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.