From edaebf2565fd4e5840d98813f6077445aa9b6bd5 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=utf8 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 Signed-off-by: Katrin Fischer Signed-off-by: Katrin Fischer Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- .../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 8cc5c9438d..1c1d6e8d2e 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(); @@ -635,15 +643,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.39.5