Bug 15774: Fix JS check when AV and MARC field are both selected
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 16 Oct 2018 19:55:18 +0000 (16:55 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 7 Mar 2019 20:37:05 +0000 (20:37 +0000)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt

index 1d85a8e..3b5309c 100755 (executable)
                 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;
             });