From 9c634a8fab0d4b837b3d8281fbeaa6ba9499ec27 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 3 Sep 2025 15:27:47 +0000 Subject: [PATCH] Bug 31698: (QA follow-up): Prevent display 'NaN' UI error message If the input is not a number, display an appropriate error message. Additionally, don't make an API call unless the input is a number. Test by doing the following: 1) Step 19: Moving record level holds, the modal says 'Enter the biblionumber of new hold target', but if you enter 'xyz' and then search, the error shown is 'No item found with barcode: NaN'. This patch fixes that. Signed-off-by: Pedro Amorim --- koha-tmpl/intranet-tmpl/prog/js/holds.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js index 6ddee9332ee..314dfc67cd6 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/holds.js +++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js @@ -986,6 +986,18 @@ $(document).ready(function () { $("#move_hold_biblio_confirm").prop("disabled", true); let biblioID = parseInt($("#biblio_id").val()); + + if (Number.isNaN(biblioID)) { + $("#biblioResultMessage").html( + '
' + + __("%s is not a valid biblionumber").format( + $("#biblio_id").val() + ) + + "
" + ); + return; + } + let apiUrl = `/api/v1/biblios?q={"biblio_id":"${encodeURIComponent(biblioID)}"}`; $.ajax({ url: apiUrl, -- 2.39.5