How to define pattern ?

  • Asked
  • Active
  • Viewed 4317 times
0
1

Hi openforis Team, I am trying to use pattern in collect earth form. I tried to research input pattern in xml but I could not understand clearly because I could not get examples what I wanted. I am trying a pattern something like this e.g. (MAK/BH/99/99). My user will input in that pattern. Will you please give me example what pattern should I define ? thank you in advance.

0

Accepted answer

Hi Rajkumar,
The pattern you can define must be a regular expression. You can find a lot of documentation and tutorials in internet about that and even live regular expression tester (see for example RegExr). In Collect Survey Designer you can define a Pattern Check for a Text attribute so that the entered values will have to match the specified regular expression. In your case the expression can be this: [A-Z]{3}\/[A-Z]{2}\/[0-9]{2}\/[0-9]{2}
That means: accept only 3 uppercase letters followed by a forward slash "/" (you have to escape it using a backward slash before it) then accept other 2 uppercase letters followed by "/" then 2 numbers and a forward slash and other 2 numbers.
Also in the Message box of the Pattern Check please specify a meaningful error message for the users. I hope this will help you.
Thanks.
Open Foris Team

Yes this worked for me.thank you very very much ricci.

Rajkumar Rajkumar

Your answer

Markdown text. Shortcuts: Ctrl+B bold, Ctrl+I italic, Ctrl+K link, Ctrl+E code, Ctrl+Shift+V paste as plain text. Tab indents list items and code; press Escape, then Tab, to leave the text box.

Insert an image

Say what the image shows, for people who can't see it.

Keyboard shortcuts

Anywhere

?
Show this list
/
Search
g h
Go to the home page
g q
Go to the questions
g t
Go to the tags
g u
Go to the users
a
Ask a question

Lists of questions

j k
Next or previous question
Enter
Open the question

Question pages

j k
Next or previous post

Shortcuts never apply while you type in a text field. Members can turn them off in their preferences.