Welcome to the LimeSurvey Community Forum

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

Validating Text Fields

  • Nazysh01
  • Nazysh01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 11 months ago #128332 by Nazysh01
Validating Text Fields was created by Nazysh01
Hi,

I am new to the league. I have been assigned Lime survey quite recently and I have hit a snag while validating text questions.
I want my text questions to accept ONLY textual response . Right now if I enter 123 in "Name of respondent" field it gets accepted. I want it to take text only.
Please help me on this. I'm afraid if the question sounds childish.
I have done my desk research already.
This is my first ever post to any forum, please help.

Cheers!
The topic has been locked.
  • Nazysh01
  • Nazysh01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 11 months ago #128340 by Nazysh01
Replied by Nazysh01 on topic Validating Text Fields
OK! I have found the solution already.
The topic has been locked.
  • tammo
  • tammo's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
8 years 11 months ago #128371 by tammo
Replied by tammo on topic Validating Text Fields
When you post your solution here, you also help other people that encounter the same problem as you had.... So please share here what solution you used.


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The topic has been locked.
  • Nazysh01
  • Nazysh01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 11 months ago #128373 by Nazysh01
Replied by Nazysh01 on topic Validating Text Fields
I have used ([A-Z]{1}[a-z]*) to validate my text fields. Later on, however, I noticed that respondents can skip this through A12345[starting with alphabet and then switching to numeric). Ideally the validation should not allow the numeric expression AT ALL.

Done so much desk research but no luck so far.

Since this is my fist ever post to any forum so I didn't know the protocols. I have posted the same question in many open discussions. I was then being told that this is off-topic and I need to initiate a new string.So did I,this morning when I escaped my own perfect logic i.e.([A-Z]{1}[a-z]*) I have started another string with the similar question(not realizing my previous string is still open) and now my post has been locked and I am being told that I need to close this string first.

Sounds mess, anyways never mind the real question remains ;How to validate text fields?????

Any clues??

A confused member!
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 11 months ago #128379 by tpartner
Replied by tpartner on topic Validating Text Fields
This regex will prevent any numeric characters. All others will be allowed.

Code:
/^([^0-9]*)$/

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: Nazysh01
The topic has been locked.
  • Nazysh01
  • Nazysh01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 11 months ago #128382 by Nazysh01
Replied by Nazysh01 on topic Validating Text Fields
Great! you saved my day @tpartner.

This is working, but i also want to prevent capital letters. Can I do that?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 11 months ago #128383 by tpartner
Replied by tpartner on topic Validating Text Fields
This should also prevent upper-case characters - anything between the square braces after the caret will be disallowed:

Code:
/^([^0-9A-Z]*)$/

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: coeneisma
The topic has been locked.
  • Nazysh01
  • Nazysh01's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 11 months ago #128386 by Nazysh01
Replied by Nazysh01 on topic Validating Text Fields
Amazing! Just what I was looking for.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose