From f6f718d09909252a9aabe3a8eee79783155fd3b7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 4 May 2019 13:08:58 -0400 Subject: [PATCH] Bug 21232: Add a client-side check on biblionumber when creating a subscription --- koha-tmpl/intranet-tmpl/prog/js/subscription-add.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js index 4c6bf22c29..9ec8d485c8 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js +++ b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js @@ -52,12 +52,25 @@ function Check_page1() { return false; } } - if ($("#biblionumber").val().length == 0) { + + var biblionumber = $("#biblionumber").val() + if ( biblionumber.length == 0 ) { alert( MSG_LINK_BIBLIO ); return false; } - return true; + var bib_exists; + $.ajax({ + url: '/cgi-bin/koha/svc/bib/' + biblionumber, + async: false, + } + ).done( + function(){ bib_exists = true; } + ).fail ( + function(){ alert(_("Bibliographic record does not exist!")); bib_exists = false; } + ); + + return bib_exists; } function Check_page2(){ -- 2.11.0