Koha/koha-tmpl/intranet-tmpl/prog/en/includes/password_check.inc
Owen Leonard 9c4f368622 Bug 22973: Remove type attribute from script tags: Staff client includes 2/2
This patch removes the "type" attribute from <script> tags in several
staff client include files. Also removed: Obsolete "//<![CDATA[ //]]>"
markers.

This patch also makes minor indentation changes, so diff using the "-w"
flag.

To test, apply the patch and confirm that examples of affected pages
work properly without any JavaScript errors in the browser console:

 - Installer -> Onboarding (uses installer-strings.inc,
   validator-strings.inc)
 - Patrons -> Patron details -> Change password (uses
   password_check.inc)
 - Patrons -> Patron details -> Print summary (slip-print.inc)
 - Circulation -> Check out (strings.inc, timepicker.inc)
 - Cataloging -> New from Z39.50/SRU (z3950_search.inc)

Validating the HTML source of any of these pages should return no errors
related to the "type" attribute.

Signed-off-by: Hayley Mapley <hayleymapley@catalyst.net.nz>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2019-05-30 10:25:21 +00:00

25 lines
1.4 KiB
PHP

[% USE Koha %]
[% BLOCK add_password_check %]
<script>
var pwd_title = "";
var pattern_title = "";
var new_password_node_name = "[% new_password | html %]";
[% IF Koha.Preference('RequireStrongPassword') %]
pwd_title = _("Password must contain at least %s characters, including UPPERCASE, lowercase and numbers").format([% minPasswordLength | html %]);
pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{[% minPasswordLength | html %],}/;
[% ELSIF minPasswordLength %]
pwd_title = _("Password must contain at least %s characters").format([% minPasswordLength | html %]);
pattern_regex = /.{[% minPasswordLength | html %],}/;
[% END %]
jQuery.validator.addMethod("password_strong", function(value, element){
return this.optional(element) || value == '****' || pattern_regex.test(value);
}, pwd_title);
jQuery.validator.addMethod("password_no_spaces", function(value, element){
return ( this.optional(element) || !value.match(/^\s/) && !value.match(/\s$/) );
}, _("Password contains leading and/or trailing spaces"));
jQuery.validator.addMethod("password_match", function(value, element){
var new_password_node = $("input[name='" + new_password_node_name + "']:first");
return value == $(new_password_node).val();
}, _("Please enter the same password as above"));
</script>
[% END %]