From 50a6fa02bac9e0bf41d5a91fe78939af4d829bd6 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 29 Aug 2016 10:54:30 +0000 Subject: [PATCH] [SIGNED-OFF] Bug 17213 - Add HTML5 validation to cardnumber field on patron self registration Content-Type: text/plain; charset="utf-8" To test: Verify that different values in 'CardnumberLength' system preference display correctly in the self reigstration form Signed-off-by: Owen Leonard --- .../bootstrap/en/modules/opac-memberentry.tt | 19 +++++++++++++++++-- opac/opac-memberentry.pl | 8 ++++++++ 2 files changed, 25 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 391c9d1..428b283 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 6dcc832..e6c1dd7 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -65,6 +65,14 @@ if ( $action eq q{} ) { my $mandatory = GetMandatoryFields($action); +my ( $min, $max ) = C4::Members::get_cardnumber_length(); +if ( defined $min ) { + $template->param( + minlength_cardnumber => $min, + maxlength_cardnumber => $max + ); + } + $template->param( action => $action, hidden => GetHiddenFields( $mandatory, 'registration' ), -- 2.1.4