From b1daa66aadead2fb781cd3ba2d71592e73a57ec2 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 29 Aug 2016 10:54:30 +0000 Subject: [PATCH] Bug 17213 - Add HTML5 validation to cardnumber field on patron self registration To test: Verify that different values in 'CardnumberLength' system preference display correctly in the self reigstration form Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Signed-off-by: Kyle M Hall --- .../bootstrap/en/modules/opac-memberentry.tt | 19 +++++++++++++++++-- opac/opac-memberentry.pl | 7 +++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index f231015be8..53401b966e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -137,8 +137,23 @@ [% IF borrower && !(cardnumber_wrong_length || cardnumber_already_exists) %] [% borrower.cardnumber %] [% ELSE %] - - [% IF mandatory.defined('cardnumber') %]Required[% END %] + [% IF minlength_cardnumber == maxlength_cardnumber %] + + [% IF ( mandatory.defined('cardnumber') ) %]Required[% END %] +
Card number must be exactly [% minlength_cardnumber %] characters.
+ [% ELSIF minlength_cardnumber && maxlength_cardnumber %] + + [% IF ( mandatory.defined('cardnumber') ) %]Required[% END %] +
Card number must be between [% minlength_cardnumber %] and [% maxlength_cardnumber %] characters.
+ [% ELSIF maxlength_cardnumber %] + + [% IF ( mandatory.defined('cardnumber') ) %]Required[% END %] +
Card number can be up to [% maxlength_cardnumber %] characters.
+ [% ELSE %] + + [% IF ( mandatory.defined('cardnumber') ) %]Required[% END %] +
There is no minimum or maximum character length.
+ [% END %] [% END %] [% END %] diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 34f9ac8289..3fd4c1f1e0 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -70,6 +70,13 @@ my @libraries = Koha::Libraries->search; if ( my @libraries_to_display = split '\|', C4::Context->preference('PatronSelfRegistrationLibraryList') ) { @libraries = map { my $b = $_; my $branchcode = $_->branchcode; grep( /^$branchcode$/, @libraries_to_display ) ? $b : () } @libraries; } +my ( $min, $max ) = C4::Members::get_cardnumber_length(); +if ( defined $min ) { + $template->param( + minlength_cardnumber => $min, + maxlength_cardnumber => $max + ); + } $template->param( action => $action, -- 2.39.5