From 7086d6fe0c97adcb61e443859a3edd2b2e48cce6 Mon Sep 17 00:00:00 2001 From: jeremy breuillard Date: Thu, 7 Jul 2022 13:55:00 +0200 Subject: [PATCH] Bug 16786: Cannot add multiple emails adresses in an email field The primary email field can allow more than one email adresses if those are separated by comma (,;) Test plan: 1) Home > Patrons 2) Create a new patron / Edit an existing patron 3) Part:'Contact information' > Field:'Primary email' : write at least 2 email adresses separated by comma 4) Try to save it... impossible 5) Apply patch and repeat 1) to 3) then save again 6) Now this field allows more than one email adress as long as there is comma separation Signed-off-by: Kyle M Hall --- koha-tmpl/intranet-tmpl/prog/js/members.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index 9ae9c18ba8d..1f1c9eccca9 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -235,10 +235,22 @@ $(document).ready(function(){ }, jQuery.validator.messages.phone); + $.validator.addMethod( + "multimail", + function(value, element, params) { + if ( value ) { + const emails = value.split(/[;,]+/); + return emails.every(email => jQuery.validator.methods.email.call(this, $.trim(email), element)) + } + return true + + }, jQuery.validator.messages.email); + $("#entryform").validate({ rules: { email: { - email: true + email: false, + multimail: true }, emailpro: { email: true -- 2.30.2