Regex for Grades

More
3 years 4 months ago #134841 by ngreis
Regex for Grades was created by ngreis
Hello

I need a valid regex for validating a input field, that goes from 0 to 20 with 3 decimal places, with comma as a decimal delimiter.

This is for people stating their grade at a certain discipline.

from 0,000 to 20,000, should be ok, negative and over 20,000 (ex 20,001+) should put the warning in the input field bold.

The regex i tried is this
^([0-9]\,[0-9][0-9])?$|(1[0-9]\,[0-9][0-9])?$|(20\,[0-9][0-9])?$
On this site, http_s://regex101.com/r/bQ5sM4/12

Seems to validate, but when placed here:


fails the warning


Thx for the help in advance

Best regards

Nuno Reis

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
3 years 4 months ago #134904 by DenisChenu
Replied by DenisChenu on topic Regex for Grades
With numeric question type : surely more easy to use min value and max value.

Regexp is done for string. For numerci string is updated to number when tested. Then 20,111 is updated to 20111.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .
The following user(s) said Thank You: ngreis

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago #134908 by ngreis
Replied by ngreis on topic Regex for Grades
Good morning

Yes, you are right, tunnel vision on my part.
Used regex for other fields before, did not even think any further.

:D

Thx

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!