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 6db0556cfd..cdfb6c94ec 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -115,6 +115,9 @@ [% IF field == "email_match" %]
  • Emails do not match! confirm email address
  • [% END %] + [% IF field == "ERROR_age_limitations" %] +
  • Patron's age is incorrect for their category. Ages allowed are [% age_low | html %]-[% age_high | html %].
  • + [% END %] [% END %] Please correct and resubmit. diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 399d31afa4..11cf05f178 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -532,6 +532,18 @@ sub CheckForInvalidFields { } } + if ( $borrower->{'dateofbirth'} ) { + my $patron = Koha::Patron->new( { dateofbirth => $borrower->{'dateofbirth'} } ); + my $age = $patron->get_age; + my $borrowercategory = Koha::Patron::Categories->find( $borrower->{'categorycode'} ); + my ( $low, $high ) = ( $borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit ); + if ( ( $high && ( $age > $high ) ) or ( $age < $low ) ) { + push @invalidFields, 'ERROR_age_limitations'; + $template->param( age_low => $low); + $template->param( age_high => $high); + } + } + return \@invalidFields; }