From bea800c67e4199f88a912c099b5b80cb1113a779 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Tue, 16 Oct 2018 16:55:18 -0300
Subject: [PATCH] Bug 15774: Fix JS check when AV and MARC field are both
 selected

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
---
 .../intranet-tmpl/prog/en/modules/admin/additional-fields.tt | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt
index 1d85a8e845..3b5309cfe4 100755
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt
@@ -189,11 +189,13 @@
                 return confirm(_("Are you sure you want to delete this field?"));
             });
 
-            $("#add_field").on('submit', function(){
-                if ( $("#marcfield").val().length > 0
-                    && $("select[name='authorised_value_category']" ).val().length > 0 ) {
-                    alert("You cannot select an authorised value category and a marcfield");
-                    return false;
+            $("#add_field").on('submit', function() {
+                if ( $("#marcfield").length && $("select[name='authorised_value_category']").length ) {
+                    if ( $("#marcfield").val().length > 0
+                        && $("select[name='authorised_value_category']" ).val().length > 0 ) {
+                        alert("You cannot select an authorised value category and a marcfield");
+                        return false;
+                    }
                 }
                 return true;
             });
-- 
2.11.0