Support Forums : Sample Pattern Rules?

We encourage an open exchange of information. Ask your questions or make suggestions. We are here to help, but we also encourage all of you to help one another.
Click on the Subscribe Flag to be notified by email of replies to your post.
Current User: Guest Login Register
Please consider registering

Sample Pattern Rules?

Add a New Topic Reply to Post
UserPost

5:15
April 17, 2007


Jennifer

Guest

I’m trying to control the possible answers for a given question by using the Pattern Rules in the Validation section. (I need the user to see an immediate “error” message or alert as they enter the information…can’t wait until user hits “submit”.)

Here are the rules I have so far:
–For a number 1-4 digits in length:
\d{1,4}

–For a whole number percentage with % sign:
\d{1,3}%

–For a three letter month:
Jan|Feb|Mar|May|Jun|Jul|Aug|Sept|Oct|Nov|Dec

(Reproduced here for the benefit of others)

Here are the other rules I’d like:
–require the user to submit info in currency
–require the user to submit an email address
–require the user to submit a phone number

Thanks!

5:30
April 17, 2007


Jennifer

Guest

Hi — a related addendum.
I am using the EXACT SAME pattern rule in two different questions. One is a “Text” question — the rule works there. The other is a “multi-textbox” question — the rule does NOT work there. I’ve tried it with the “Other” boxes checked and un-checked. Still doesn’t work.

Any advice?

7:58
April 18, 2007


Christian Vanek

Moderator

Cambridge, MA

posts 784

Good catch!

The multi-text questions now allow for the same pattern matching behavior. Plus, here are your other patterns. BTW. You may need to add a ^ to the beginning of your patten and a $ to the end to get them to work more preceisely.

So the 4 digit pattern would be: ^\d{1,4}$

Here are the others you wanted (brace yourself!):

Currency: (with commas dollar sign and cents)
^\$?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$

Email Address:
^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$

US Phone Number:
^((\(\d{3}\) ?)|(\d{3}[-\s]))?\d{3}[-\s]\d{4}$

11:49
April 26, 2007


Jennifer

Guest

So the pattern rule works when I have a single text question, and it works when I have a multi-text question…but it won’t seem to work if I have “table” question with the type as “multiple-answer per row (open ended)”.

Is that something you can change, or is there some type of logic that prevents it?

Thanks!

12:07
April 26, 2007


Scott McDaniel

Moderator

posts 94

You’re right Jennifer. We don’t currently have validation working on text fields in a table like this yet.

12:45
May 18, 2007


Jennifer

Guest

Hi - me again. Another question on this subject….

How can I set a minimum for an answer (multiple textbox set-up)? And can I set a minimum for each text box row?

In the “Pattern-based Input Mask RegEx” field, I have this:
^\d*$
I want the user to enter a number that is at minimum 50,000. What can I add to make that a rule?

Ideally, I’d have a different minimum for each textbox entry. Do I need to change to a series of individual textboxes?

I’m trying to get the user to tell me what they’ve spent on 4 different things, I know the minimum spend possible, so I want to help them enter the correct data.

Thanks for your help!

2:13
May 23, 2007


Christian Vanek

Moderator

Cambridge, MA

posts 784

Hi Jennifer,

Sorry it took us a few days to get to this. This post slipped through the cracks.

There is the RegEx you need:

^((([5-9][0-9],[0-9]{3,3})|(\d,(\d\d\d,){0,5}\d\d\d,\d\d\d))|(([5-9]\d{4,4})|(\d{6,12})))$

The reason it looks so complex is because it need to handle numbers with commas and numbers without commas :)

-Christian

1:03
March 24, 2008


mhamilton-jones@cnomail.org

Member

posts 7

Hi,

I need to validate someone’s registration number that they enter in a text box:

The number can be one of two formats:
Either:
Two letters (from A to J) followed by 5 numbers, e.g. CJ12345

Or:
7 numbers (the first of which has to be a 0,4,5,6,7,8,9) e.g. 0512345

Any help you can provide would be greatly appreciated.
Thanks!

10:58
March 25, 2008


mhamilton-jones@cnomail.org

Member

posts 7

I found the answer to my question from someone else on my team. For anyone who’s interested, the following seems to work.
^(([D-Jd-j]{1}[A-Ja-j]{1})|([04-9]{1}[0-9]{1}))[0-9]{5}$

I didn’t specify in my original question that the first digit had to be either D,E,F,G,H,I,J OR 0,4,5,6,7,8,9

Add a New Topic Reply to Post


Reply to Topic: Sample Pattern Rules?

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 11 + 2        (Required)

Topic Reply:


 
© Simple:Press Forum - Version 3.1.4 (Build 357)