From 5b185b6815fdf4824d65d56efdebe7b316c065a7 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 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) If you try to type again, the error message will show up. 5) if you backspace some characters, the message should disappear Sponsored-by: Catalyst IT --- .../prog/en/modules/members/memberentrygen.tt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 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..7d825b3 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").keypress(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,19 +621,19 @@ $(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 %] - [% IF mandatorycardnumber and not autoMemberNum %]Required[% END %] + [% IF mandatorycardnumber and not autoMemberNum %]Required[% END %]Card number must not be more than [% maxlength_cardnumber %] characters.
There is no minimum or maximum character length.
[% END %] -- 2.1.4