Bug 17098 - Validation problems with form field type "number" (decimal separator)
Summary: Validation problems with form field type "number" (decimal separator)
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Galen Charlton
QA Contact: Testopia
URL:
Keywords:
Depends on: 21507
Blocks:
  Show dependency treegraph
 
Reported: 2016-08-10 06:28 UTC by Marc Véron
Modified: 2020-08-19 07:26 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Véron 2016-08-10 06:28:19 UTC
With Koha language set to de-DE, it is not possible to enter numeric values with decimal separator point like 5.00 if the input field is of type "numeric". Validation requires comma (,)

Independently on Koha language and CurrencyFormat settings, you get an error message (in German): "Bitte geben Sie eine Nummer ein."

To verify:
- Install language de-DE (alternatively use Firebug to manipulate page HTML to <html lang="de-DE"> or to set lang="de-DE directly in form field).
- Go to /cgi-bin/koha/members/maninvoice.pl?borrowernumber=XXX ("Manuelle Gebühr")
- In field "Betrag:", enter 5.00
Result: Field border turns to red, field shows tooltip "Bitte geben Sie eine Nummer ein."

Expected result: Point as decimal separator is accepted.

Same behaviour with it-IT, fr-FR, nl-NL

However if you set language to en or de-CH, both comma and point are accepted.
Comment 1 Marc Véron 2016-08-10 06:48:25 UTC
More information:

Discussion on IRC: http://irc.koha-community.org/koha/2016-08-09#i_1847065

Bug 12310 - Accept different monetary formats as input
Comment 2 Marc Véron 2016-08-10 07:24:05 UTC
Files with input type "numeric" (git grep --files-with-matches 'type="number"'):

Decimal:
koha-tmpl/intranet-tmpl/prog/en/modules/members/mancredit.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt

Only digits (no problem):
koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt
Comment 3 Katrin Fischer 2016-10-18 08:17:50 UTC
We are currently running into this - it's irritating for the libraries tht sometimes you have to use . and other times you have to use , - There is a lot of error potential if you are not careful. Updating severity a bit.
Comment 4 Katrin Fischer 2017-03-09 10:36:13 UTC
At the moment this problem exists in 2 files: maninvoice.tt and mancredit.tt. Pasting the fix we did on our installations here for making a proper patch later:


--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt
@@ -70,7 +70,7 @@ type_fees['[% invoice_types_loo.authorised_value %]'] = "[% invoice_types_loo.li
        <li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" /></li>
        <li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" /></li>
     <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" /></li>
-    <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li>
+    <li><label for="amount">Amount: </label><input type="text" pattern="\d+(\.\d{2})?" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li>
        </ol></fieldset>
 <fieldset class="action"><input type="submit" name="add" value="Save" /> <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% borrowernumber %]">Cancel</a></fieldset>
 </form>
Comment 5 Jonathan Druart 2017-03-13 13:06:20 UTC
I do not recreate, on /members/maninvoice.pl?borrowernumber=5, I tried with FF ESR 45.4.0 and Chromium 55.0.2883.75.
With de-DE, I do see lang=de-DE, but 12.3 and 12,3 are ok
Comment 6 Jonathan Druart 2017-03-13 13:22:09 UTC
If we simply replace type="number" with type="text", we will reintroduce bug 2542.
Comment 7 Jonathan Druart 2017-03-13 13:22:52 UTC
(In reply to Jonathan Druart from comment #6)
> If we simply replace type="number" with type="text", we will reintroduce bug
> 2542.

That could work using the pattern attribute indeed.
Comment 8 Katrin Fischer 2017-03-14 11:22:08 UTC
(In reply to Jonathan Druart from comment #5)
> I do not recreate, on /members/maninvoice.pl?borrowernumber=5, I tried with
> FF ESR 45.4.0 and Chromium 55.0.2883.75.
> With de-DE, I do see lang=de-DE, but 12.3 and 12,3 are ok

Hm. That's odd. Might be some change in browser behaviour? We are using ESR at work too. Will retest.
Comment 9 Katrin Fischer 2018-03-01 11:18:16 UTC
I ended up patching it like that:

-    <li><label for="amount">Amount: </label><input type="number" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li>
+    <li><label for="amount">Amount: </label><input type="text" pattern="\d+(\.\d{2})?" name="amount" id="amount" required="required" value="" step="any" min="0" /> Example: 5.00</li>
Comment 11 Katrin Fischer 2020-08-19 07:24:20 UTC
It could be a mix of having a "German" firefox installed and Plack and other settings... we have seen some weird things happening. See bug 18186.
Comment 12 Martin Renvoize (ashimema) 2020-08-19 07:26:49 UTC
Popping this in here so we don't loose it.

https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/