Bug 18298: Use the validate jQuery plugin
[koha_ffzg] / koha-tmpl / intranet-tmpl / prog / en / modules / members / member-password.tt
1 [% USE Koha %]
2 [% USE Branches %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Patrons &rsaquo; [% IF ( newpassword ) %]Password updated [% ELSE %]Update password for [% surname %], [% firstname %][% END %]</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 <script type="text/JavaScript">
7 //<![CDATA[
8
9     $(document).ready(function() {
10         $("body").on('click', "#fillrandom",function(e) {
11             e.preventDefault();
12             $.get("/cgi-bin/koha/members/member-password.pl?member=[% userid %]", function(response) {
13                 var defaultnewpass = $(response).find("#defaultnewpassfield").val();
14                 $("#newpassword").after("<input type=\"text\" name=\"newpassword\"  id=\"newpassword\" value=\"" + defaultnewpass + "\">").remove();
15                 $("#newpassword2").after("<input type=\"text\" name=\"newpassword2\" id=\"newpassword2\" value=\"" + defaultnewpass + "\">").remove();
16             });
17         });
18         $("div.hint").eq(0).after(" <div class=\"hint\"><a href=\"#\" id=\"fillrandom\">"+_("Click to fill with a randomly generated suggestion. ")+"<strong>"+_("Passwords will be displayed as text")+"</strong>.</a></div>");
19
20         $(document).ajaxStart(function () {
21             $("input[name^=newpassword]").hide();
22             $("label[for=newpassword2]").hide();
23             $(".hint:last").after($(".loading").show());
24         });
25         $(document).ajaxStop(function () {
26             $("input[name^=newpassword]").show();
27             $("label[for=newpassword2]").show();
28             $(".loading").hide();
29             $("label.error").hide();
30         });
31         [% IF NOMATCH %]
32             $("#newpassword").addClass('focus');
33         [% END %]
34
35         $("#changepasswordf").validate({
36             rules: {
37                 newpassword: {
38                     required: true,
39                     password_strong: true,
40                     password_no_spaces: true
41                 },
42                 newpassword2: {
43                     required: true,
44                     password_match: true
45                 }
46             }
47         });
48     });
49 //]]>
50 </script>
51 </head>
52 <body id="pat_member-password" class="pat">
53 [% INCLUDE 'header.inc' %]
54 [% INCLUDE 'patron-search.inc' %]
55
56 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>  &rsaquo; <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% firstname %] [% surname %]</a> &rsaquo; [% IF ( newpassword ) %]Password Updated[% ELSE %]Change username and/or password[% END %]</div>
57
58 <div id="doc3" class="yui-t2">
59
60    <div id="bd">
61         <div id="yui-main">
62         <div class="yui-b">
63 [% INCLUDE 'members-toolbar.inc' %]
64
65 [% IF ( newpassword ) %]
66 <h1>Password Updated</h1>
67
68 [% ELSE %]
69
70 <form method="post" id="changepasswordf" action="/cgi-bin/koha/members/member-password.pl">
71 <input type="hidden" name="destination" value="[% destination %]" />
72 <input type="hidden" name="cardnumber" value="[% cardnumber %]" />
73 <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber %]" />
74         [% IF ( errormsg ) %]
75                 <div class="dialog alert">
76                 <h4>The following errors have occurred:</h4>
77                 <ul>
78                 [% IF ( BADUSERID ) %]
79         <li>You have entered a username that already exists. Please choose another one.</li>
80                 [% END %]
81                 [% IF ( SHORTPASSWORD ) %]
82                 <li><strong>The password entered is too short</strong>. Password must be at least [% minPasswordLength %] characters.</li>
83                 [% END %]
84                 [% IF ( NOPERMISSION ) %]
85                 <li>You do not have permission to edit this patron's login information.</li>
86                 [% END %]
87                 [% IF ( NOMATCH ) %]
88                 <li><strong>The passwords entered do not match</strong>. Please re-enter the new password.</li>
89                 [% END %]
90                 </ul>
91                 </div>
92         [% END %]
93
94
95     <fieldset class="brief"><legend>Change username and/or password for [% firstname %] [% surname %]</legend>
96         <ol>
97     <li><label for="newuserid">New username:</label>
98         <input type="hidden" name="member" value="[% borrowernumber %]" /><input type="text" id="newuserid" name="newuserid" size="20" value="[% userid %]" /></li>
99     [% SET password_pattern = ".{" _ minPasswordLength _ ",}" %]
100     [% IF Koha.Preference('RequireStrongPassword') %]
101         [% SET password_pattern = '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{' _ minPasswordLength _ ',}' %]
102     [% END %]
103     <li>
104         <label for="newpassword">New password:</label>
105         <div class="hint">Koha cannot display existing passwords. Leave the field blank to leave password unchanged.</div>
106         <input name="newpassword"  id="newpassword" type="password" size="20" />
107     </li>
108     <li>
109         <label for="newpassword2">Confirm new password:</label>
110         <input name="newpassword2"  id="newpassword2" type="password" size="20" />
111     </li>
112         </ol>
113 </fieldset>
114     <fieldset class="action">
115         <input type="hidden" name="csrf_token" value="[% csrf_token %]" />
116         <input type="submit" value="Save" />
117         <a class="cancel" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">Cancel</a>
118     </fieldset>
119 </form>[% END %]
120
121 </div>
122 </div>
123 <input type="hidden" name="defaultnewpassfield" id="defaultnewpassfield" value="[% defaultnewpassword %]" />
124 <div class="loading hide"><strong>Processing...</strong><img src="[% interface %]/[% theme %]/img/loading.gif" alt="" /></div>
125 <div class="yui-b">
126 [% INCLUDE 'circ-menu.inc' %]
127 </div>
128 </div>
129 [% INCLUDE 'intranet-bottom.inc' %]
130 [% PROCESS 'password_check.inc' %]
131 [% PROCESS 'add_password_check' new_password => 'newpassword' %]