Entering phone # contact information

More
3 years 1 month ago #108341 by jpw
jpw created the topic: Entering phone # contact information
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.

Please Log in to join the conversation.

More
3 years 1 month ago - 3 years 1 month ago #108342 by Ben_V
Ben_V replied the 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: 3 years 1 month ago by Ben_V.

Please Log in to join the conversation.

More
3 years 1 month ago #108343 by jpw
jpw replied the 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.

Please Log in to join the conversation.

More
3 years 1 month ago - 3 years 1 month ago #108344 by Ben_V
Ben_V replied the topic: Entering phone # contact information

"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. "

Found here

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: 3 years 1 month ago by Ben_V.

Please Log in to join the conversation.

More
3 years 1 month ago #108347 by jpw
jpw replied the 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.

Please Log in to join the conversation.

More
3 years 1 month ago #108363 by Ben_V
Ben_V replied the 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):
/^(?:\([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)

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now