- Posts: 15
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Entering phone # contact information
- jpw
- Topic Author
- Offline
- New Member
Less
More
9 years 11 months ago #108341
by jpw
Entering phone # contact information was created by jpw
I want to have respondents enter their phone # contact information (US) with fields for the area code (xxx), prefix xxx, a "-" character, suffix xxxx and ext. (up to 8 characters). Is there a way to have separate validation expressions for each field. In other words, can I have a before and after () for the area code but only allow the #s 2-9 as the leading digit for the area code; only allow 3 digits for the prefix with the leading digit from 2-9; only allow 4 digits for the suffix.
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
9 years 11 months ago - 9 years 11 months ago #108342
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Entering phone # contact information
Do you mean that you need other validation than regex
available here
?
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last edit: 9 years 11 months ago by Ben_V.
The topic has been locked.
- jpw
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 0
9 years 11 months ago #108343
by jpw
Replied by jpw on topic Entering phone # contact information
I'm new to LimeSurvey and JavaSript, trying to "learn on the fly". I'm trying to create an array (texts or numbers) question with home/cell/work/other on the y-scale and area code, prefix, suffix, and ext on the x-scale. I wanted to have separate validation expressions for each of the area code, and prefix fields as well as only allow integers for all fields.
I wasn't sure if this was just too complicated for me to attempt and I should just enter the full # as one field with a separate field for the ext. In that case, I wasn't sure how to include the phone # validation expression for just the phone # fields and not the ext. fields.
I wasn't sure if this was just too complicated for me to attempt and I should just enter the full # as one field with a separate field for the ext. In that case, I wasn't sure how to include the phone # validation expression for just the phone # fields and not the ext. fields.
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
9 years 11 months ago - 9 years 11 months ago #108344
by Ben_V
On the other hand, you can use 4 (home/cell/work/other) separate (text) questions with one of the regular expression provided above. It's easier and much better for small devices users
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Entering phone # contact information
Found here"Validation can be applied to individual cells within an array, such as this example where regular expression validations ensure that each entry is a properly formatted US phone number including area code. "
On the other hand, you can use 4 (home/cell/work/other) separate (text) questions with one of the regular expression provided above. It's easier and much better for small devices users
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Last edit: 9 years 11 months ago by Ben_V.
The topic has been locked.
- jpw
- Topic Author
- Offline
- New Member
Less
More
- Posts: 15
- Thank you received: 0
9 years 11 months ago #108347
by jpw
Replied by jpw on topic Entering phone # contact information
Thanks for your help! I'm still a little confused on how to enter the validation codes if I use separate text questions for home/cell/etc. If for example the home # question is an array (number or texts)question type and I want different validation expressions for the area code, prefix, and suffix fields; how do I separate the expressions for each filed? Would it be in the subquestion validation expression box and if so what syntax is used to ensure each expression checks the correct field.
The topic has been locked.
- Ben_V
- Offline
- Platinum Member
Less
More
- Posts: 1128
- Thank you received: 329
9 years 11 months ago #108363
by Ben_V
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
Replied by Ben_V on topic Entering phone # contact information
I can't provide you the requiered expressions because I know very few things on how to set regex
Maybe you can have a look inside the complete regex for us phones, and try to retrieve some components...
For example, I think that the following expression, can validate a number from 200 to 999 (not tested):
Try it in a "subquestion validation expression box"
Maybe you can have a look inside the complete regex for us phones, and try to retrieve some components...
For example, I think that the following expression, can validate a number from 200 to 999 (not tested):
Code:
/^(?:\([2-9]\d{2}\)\ ?|[2-9]\d{2})$/
Try it in a "subquestion validation expression box"
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
The topic has been locked.