From 6a1fd17c411f4bb566bde95d58efd0cc1f3d2116 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Thu, 20 Apr 2017 03:35:47 +0000 Subject: [PATCH] Bug 10267: Show error message if user tries to enter too many characters for cardnumber MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch displays a message if the user tries to enter more than the max number of characters for a cardnumber. To test: 1) Apply patch and go to Patrons -> New patron 2) Scroll down to Card number 3) Put in any characters. Notice that when you have entered the max number of characters, you are unable to type any more. 4) Click out of the text field (so it loses focus), the error message will show up. 5) if you backspace some characters and click out of the text field again, the message should disappear Sponsored-by: Catalyst IT Followed test plan, works as expected Signed-off-by: Marc VĂ©ron --- .../prog/en/modules/members/memberentrygen.tt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index ff3ef68..f12d83f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -36,7 +36,15 @@ $(document).ready(function() { }); $(document).ready(function() { - + $("#cn_max").hide(); + var max_len = [% maxlength_cardnumber %]; + $("#cardnumber").change(function(){ + if ( $("#cardnumber").val().length >= max_len ) { + $("#cn_max").show(); + } else { + $("#cn_max").hide(); + } + }); var toggle_quick_add = $(".toggle_quick_add"); $(toggle_quick_add).click(function(e){ toggle_quick_add.toggle(); @@ -613,15 +621,15 @@ $(document).ready(function() { [% END %] [% IF minlength_cardnumber == maxlength_cardnumber %] - [% IF mandatorycardnumber and not autoMemberNum %]Required[% END %] + [% IF mandatorycardnumber and not autoMemberNum %]Required[% END %]Card number must not be more than [% maxlength_cardnumber %] characters.
Card number must be exactly [% minlength_cardnumber %] characters.
[% ELSIF minlength_cardnumber && maxlength_cardnumber %] - [% IF mandatorycardnumber and not autoMemberNum %]Required[% END %] + [% IF mandatorycardnumber and not autoMemberNum %]Required[% END %]Card number must not be more than [% maxlength_cardnumber %] characters.
Card number must be between [% minlength_cardnumber %] and [% maxlength_cardnumber %] characters.
[% ELSIF maxlength_cardnumber %] - [% IF mandatorycardnumber and not autoMemberNum %]Required[% END %] + [% IF mandatorycardnumber and not autoMemberNum %]Required[% END %]Card number must not be more than [% maxlength_cardnumber %] characters.
Card number can be up to [% maxlength_cardnumber %] characters.
[% ELSE %] -- 2.1.4