The Value You Entered Within the Textbox Contained Nonnumeric Characters Try Again Java
What do you demand aid with?
Search the knowledge base, scan our resources and visit our forum for more detail data
Restricting Text Responses With Regular Expressions¶
Concluding updated: 15 Feb 2022
A regular expression, or regex, is a search pattern used for matching specific characters and ranges of characters within a string. It is widely used to validate, search, extract, and restrict text in virtually programming languages. KoboToolbox supports regex to control the length and characters during data entry to a particular question (e.g. decision-making the entry of mobile number to exactly 10 digits, controlling the entry of a valid electronic mail id etc.).
To use a regex in KoboToolbox, follow these steps¶
-
Set up a Text question type.
-
Go to the question'south Settings.
-
Become to Validation Criteria and choose the Manually enter your validation logic in XLSForm code option.
-
In the Validation Code box, enter your regex formula between the quotation marks
(' ')of theregex(., ' ')format. For reference, the menstruum (.) refers to 'this question', while the regular expression within the quotation marks (' ') needs to adjust to the established regex rules. -
(Optional) Add together a custom Error Message for the person entering data to see when they don't come across the regex criteria.
Regex can besides be coded in XLSForm, nether the constraint column:
| blazon | proper name | label | advent | constraint | constraint_message |
|---|---|---|---|---|---|
| text | q1 | Mobile number of respondent | numbers | regex(., '^[0-9]{10}$') | This value must exist only x digits |
Alternatively, you can create a calculate question type and so define the regex code under the calculation column. You lot could then use this variable as many times as needed in the survey:
| blazon | proper name | label | adding | constraint | constraint_message |
|---|---|---|---|---|---|
| calculate | q0 | '^[A-Z]{i}[a-z]{one,}\s[A-Z]{1}[a-z]{1,}$' | |||
| text | q1 | Name of the Enumerator | regex(., ${q0}) | Please use this format: Kobe Bryant | |
| text | q2 | Proper noun of the Respondent | regex(., ${q0}) | Please utilize this format: Kobe Bryant | |
| integer | q3 | Age of the Respondent |
How exercise I build the regex that I demand?¶
In addition to the examples and tips provided below, please visit this website for more help and examples.
Regex in KoboToolbox should ever be written in-between the apostrophes regex(., ' ') as shown in the examples.
| Regex | Clarification |
|---|---|
| | The caret symbol matches the starting time of a string without consuming whatsoever character. |
| | The dollar symbol matches the terminate of a string without consuming any character. |
| | Matches either |
| | Matches whatever lowercase character from |
| | Matches whatever uppercase character from |
| | Matches any whole numbers from |
| | Matches whatsoever character from |
| | Matches whatsoever graphic symbol except |
| | Matches whatever characters except those in the range |
| | The group character |
| | A vertical bar matches any element separated. |
| | A dorsum slash is used to friction match the literal value of any metacharacter (east.yard. endeavour using |
| | Matches the aforementioned character as almost recently matched by the northwardth (number used) capturing grouping. |
| | Matches any space or tab. |
| | Matches, without consuming whatever characters immediately between a character matched past |
| | Matches any equivalent numbers |
| | Matches annihilation other than numbers |
| | Matches whatever discussion character (i.e. |
| | Matches anything other than what |
| | A question marking used merely behind a graphic symbol matches or skips (if non required) a graphic symbol match. |
| | An asterisk symbol used simply behind a character matches aught or more consecutive character. |
| | The plus symbol used just behind a graphic symbol matches i or more consecutive character. |
| | Matches exactly |
| | Matches at least |
| | Matches betwixt |
Examples related to utilise of numbers¶
For all text type questions that utilize numbers, do not forget to blazon numbers under the appearance cavalcade.
| XLSForm Regex | Description |
|---|---|
| | Restrict mobile number to ten digits |
| | Restrict an input to |
| | Restrict an input between |
| | Restrict an input to either to |
| | Restrict an input of ix digits where the showtime number can't be |
| | Restrict an input to one digit in between |
| | Restrict an input to five digits in between |
| | Restrict an input to two digits and three decimals (e.g. |
| | Restrict an input to 2 digits and iii decimals (while the decimals are optional) (e.thou. |
Examples related to use of letters¶
| XLSForm Regex | Description |
|---|---|
| | Restrict an input to any lowercase letters (up to 6 characters long) |
| | Restrict an input to any capital letter letters (upwards to 10 characters long) |
| | Restrict an input to only either to |
| | Restrict an input to only |
| | Restrict an input with a valid email address |
| | Restrict an input of the beneficiaries proper noun where the initials of the first proper noun and last name are majuscule e.g. |
| | Restrict an input of the beneficiaries name with first name, middle name (if any) and last name due east.g. |
| | Restrict an input of the beneficiaries' total proper noun where the initials of the names are in uppercase and the proper noun are quite long (often greater than three words) e.thousand. |
| | Restrict an input of the beneficiaries' kickoff name (and so that you are able to capture the exact spelling) where the enumerators are forced to enter the beneficiaries get-go name twice east.g. |
| | Restrict an input of the beneficiaries' last name (and then that you are able to capture the verbal spelling) where the enumerators are forced to enter the beneficiaries last name twice e.m. |
| | Restrict a character within a word by using the |
| | Restrict a character within a word by using the |
| | Restrict a character within a give-and-take by using the |
| | Restrict an input to a not-digit grapheme (due east.grand. |
| | Restrict an input to v non-digit grapheme (e.1000. |
Examples related to employ of a combination of messages and numbers¶
| XLSForm Regex | Description |
|---|---|
| | Restrict one character which matches betwixt |
| | Restrict iii character which matches between |
| | Restrict your beneficiary ID to a specific format due east.g. |
| | Restrict your casher ID to a specific format e.one thousand. |
| | Restrict a currency input of three digits with a currency sign (either |
| | Restrict an exact input of number of words (e.g. to restrict exactly iii words |
| | Restrict an input of number of words (e.g. to restrict a range of words say |
Considerations when using regex¶
-
If you wish to use a regex constraint on a number in a
textblazon question, make sure you e'er have the valuenumbersunder theappearancecolumn. This restricts the display of alphabets, making only numbers visible for inputs. -
The Collect Android app and Enketo comport differently with their treatment of regex expressions. Collect behaves as if you have used the anchors
^and$around the expression (even if yous accept not used them), while Enketo requires the anchors as mandatory for an verbal match.
Was this article useful?
Did you lot find what you lot were looking for? Was the information articulate? Was anything missing?
Share your feedback to help the states improve this article!
Source: https://support.kobotoolbox.org/restrict_responses.html
0 Response to "The Value You Entered Within the Textbox Contained Nonnumeric Characters Try Again Java"
ارسال یک نظر