Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

My regular expression don't work. Someboy can help-me? Thanks.

  • diegoaraujocastro
  • diegoaraujocastro's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #145230 by diegoaraujocastro
Dear friends,

I need to validate a process number with 17 digits:
99999.999999/9999-99.
This expression works:
/^[0-9]{5}\.[0-9]{6}\/[0-9]{4}-[0-9]{2}$/
BUT the problem is that user need to add dots, bars and trace manually.

When I try to exclude "\" before these elements, like the example below, I didn't take the same result:
Number:
999.999.999-99.
Validation: /^[0-9]{3}.[0-9]{3}.[0-9]{3}-[0-9]{2}$/
In this example. the user have points e trace autofill.

I know that I put a number more than 3 in the validation formula don't work.

There is a solution to add dots, bars and traces automatically when the user insert the information (in the first example)?

Thanks a lot!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145265 by tpartner
A regex can't insert characters for you. You'll need to use an input mask - digitalbush.com/projects/masked-input-plugin/ .

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145268 by tpartner

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145348 by DenisChenu
Note for me : plugin idea ;)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • diegoaraujocastro
  • diegoaraujocastro's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #145371 by diegoaraujocastro
Dear friends,

Thanks for help.

Unfortunately, I don't have acess to limesurvey's directory: only the webpage. :(

In the second example, why it works? Maybe have a input mask for this in the code?

Thanks.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145376 by tpartner
I have no clue how a validation regex could insert characters.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • diegoaraujocastro
  • diegoaraujocastro's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #145377 by diegoaraujocastro

I have no clue how a validation regex could insert characters.


In the fisrt pic below, I start do type 002 and the dot is automaticaly completed:

In example, I start do type "002.831. (and these dots are automaticaly completed)

In validate regx we have the code of second pic of these post.

Its probable that have a plugin code with CPF mask in the limesurvey's folder?

Thanks
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145383 by tpartner
I don't know of any masks like that in the core LimeSurvey code and cannot reproduce it on any of my versions.

What version are you using?
What template are you using?
Have you tested with the default template?
Can you attach a small sample survey?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • diegoaraujocastro
  • diegoaraujocastro's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 3 months ago #145391 by diegoaraujocastro
What version are you using? 2.05+ Build 141229
What template are you using? It's a template especific for my organization, but I imagine that the almost modification are only in design.
Have you tested with the default template? Only now. Are your a genious! In default template, limesurvey didnt't autocomplete like second example of my topic. I'll need to contact my IT area to modify lime template and include this mask, it's out of my control.

Congratulations! Finally I can discovery the cause of my regex don't work like other type of number in my form.

God bless you! :)
Attachments:
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 months ago #145399 by Joffm
Hi, diego,

well, just to remind:
there is a topic in the manual about masked input
manual.limesurvey.org/Workarounds:_Manip...asks_-_second_method

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose