View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
12851Bug reports_ Unknownpublic2018-01-15 10:39
Reporterlpetersen Assigned Tomarkusfluer 
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Product Version2.7x.x 
Fixed in Version3.0.0-rc.x 
Summary12851: Regex for trailing zeroes in numeric input matches only zeroes immediately after decimal sign
Description

In a (non-integer) numeric input field, I can enter, e.g.,
1.00
but not, e.g.,
1.200

This is bothersome when I want to enter a value like
1.2003
which is only possible by entering 1.23 first, then using the left arrow key and inserting the 0's afterwards.

Steps To Reproduce

Create a survey with a "numeric" input type question, preview that question and try entering 1.2003 into the numeric input field.

Additional Information

Function fixnum_checkconditions in survey_runtime.js seems to prevent cutting off trailing zeroes in a numeric input field by the following code (lines 216-):

    var matchFollowingZeroes =  cleansedValue.match(/^-?([0-9])*(,|\.)(0+)$/);
    if(matchFollowingZeroes){
        addition = LEMradix+matchFollowingZeroes[3];
    }

The third group of the regex in the first line, however, does not match trailing zeroes which do not immediately follow the decimal sign. The following change should fix this:

    var matchFollowingZeroes =  cleansedValue.match(/^-?([0-9])*(,|\.)(([0-9]*[1-9])?(0+)$/);
    if(matchFollowingZeroes){
        addition = LEMradix+matchFollowingZeroes[5]; // Now it's the fifth group to match
    }

As far as I can see, this patch should also apply to the development version.

Thank you for your work and this great software!

TagsNo tags attached.
Bug heat6
Complete LimeSurvey version number (& build)2.72.3 (build 171020)
I will donate to the project if issue is resolvedNo
BrowserChromium Version 62.0.3202.62 (Official Build) Built on Ubuntu , running on Ubuntu 17.10 (64-Bit)
Database type & versionMariaDB 10.1.26-MariaDB-0+deb9u1
Server OS (if known)Debian 9.1
Webserver software & version (if known)Apache/2.4.25 (Debian)
PHP Version7.0.23-1~dotdeb+8.1

Users monitoring this issue

There are no users monitoring this issue.

Activities

lpetersen

lpetersen

2017-10-30 12:05

reporter   ~44897

Sorry, I've just seen that the issue is slightly more complex than I thought. The decimal sign needs to be added only when it was suppressed due to the input having no decimals at all, but not otherwise.

This should do the trick now (but as you've seen, you shouldn't trust my regex skills):

    var matchFollowingZeroes =  cleansedValue.match(/^-?[0-9]*((,|\.)[0-9]*[1-9]|(,|\.))(0+)$/);
    if(matchFollowingZeroes){
        addition = (matchFollowingZeroes[3] || '')+matchFollowingZeroes[4];
    }

Sorry for any confusion created.

markusfluer

markusfluer

2017-10-30 12:43

administrator   ~44899

Fix committed to develop branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=24330

markusfluer

markusfluer

2017-10-30 12:51

administrator   ~44900

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=24331

c_schmitz

c_schmitz

2018-01-15 10:39

administrator   ~45759

Version 3.0.3 released.

Related Changesets

LimeSurvey: develop c06d5673

2017-10-30 12:42:58

markusfluer

Details Diff
Fixed issue 12851: Regex for trailing zeroes in numeric input matches only zeroes immediately after decimal sign Affected Issues
12851
mod - application/helpers/SurveyRuntimeHelper.php Diff File
mod - assets/scripts/survey_runtime.js Diff File

LimeSurvey: master d57b1463

2017-10-30 12:51:05

markusfluer

Details Diff
Fixed issue 12851: Regex for trailing zeroes in numeric input matches only zeroes immediately after decimal sign Affected Issues
12851
mod - scripts/survey_runtime.js Diff File

Issue History

Date Modified Username Field Change
2017-10-30 11:16 lpetersen New Issue
2017-10-30 12:05 lpetersen Note Added: 44897
2017-10-30 12:43 markusfluer Assigned To => markusfluer
2017-10-30 12:43 markusfluer Status new => resolved
2017-10-30 12:43 markusfluer Resolution open => fixed
2017-10-30 12:43 markusfluer Fixed in Version => 3.0.0-rc.x
2017-10-30 12:43 markusfluer Changeset attached => LimeSurvey develop c06d5673
2017-10-30 12:43 markusfluer Note Added: 44899
2017-10-30 12:51 markusfluer Changeset attached => LimeSurvey master d57b1463
2017-10-30 12:51 markusfluer Note Added: 44900
2018-01-15 10:39 c_schmitz Note Added: 45759
2018-01-15 10:39 c_schmitz Status resolved => closed