Field Types and Field Validation
Field Types
The field type dictates how the field will be shown on the data entry form. It also changes how the data is stored.
Online Designer | Data Dictionary code | Description |
Text Box | text | single-line text box (for text, numbers, and dates/times) |
Notes Box | notes | large text box for lots of text |
Calculated Field | calc | perform real-time calculations |
Multiple Choice - Drop-down list | dropdown | dropdown menu with single-choice options |
Multiple Choice - Radio Buttons | radio | radio buttons with single-choice options |
Checkboxes | checkbox | checkboxes to allow selection of more than one option |
Yes - No | yesno | radio buttons with yes and no options coded as 1, Yes | 0, No |
True - False | truefalse | radio buttons with true and false options coded as 1, True | 0, False |
Signature | file | draw and upload a signature |
File Upload | file | upload a document |
Slider | slider | visual analog scale coded as 0-100 by default |
Descriptive Text | desc | text displayed with no data entry and optional image/file attachment |
Begin New Section |
| creates a header section in the form |
Dynamic Query | sql | (requires administrator to setup) Select query statement to populate dropdown choices |
Field Validation
Text fields allow for validation to be used, enforcing only specific types of data to be entered.
Online Designer | Data Dictionary code | Example | Notes |
Date (D-M-Y) | date_dmy | 31-12-2008 |
|
Date (M-D-Y) | date_mdy | 12-31-2008 |
|
Date (Y-M-D) | date_ymd | 2008-12-31 |
|
Datetime (D-M-Y H:M) | datetime_dmy | 16-02-2011 17:45 |
|
Datetime (M-D-Y H:M) | datetime_mdy | 02-16-2011 17:45 |
|
Datetime (Y-M-D H:M) | datetime_ymd | 2011-02-16 17:45 |
|
Datetime w/ seconds | datetime_seconds_dmy | 16-02-2011 17:45:23 |
|
Datetime w/ seconds | datetime_seconds_mdy | 02-16-2011 17:45:23 |
|
Datetime w/ seconds | datetime_seconds_ymd | 2011-02-16 17:45:23 |
|
john.doe@vanderbilt.edu |
| ||
Integer | integer | 1, 4, -10 | whole number with no decimal |
Letters only | alpha_only | name | letters only, no numbers, spaces, or special characters |
Number | number | 1.3, 22, -6.28, 3.14e-2 | a general number or scientific notation (no spaces) |
Number (1 decimal place, comma as decimal) | number_1dp_comma_decimal | 50,2 |
|
Number (1 decimal place) | number_1dp | 50.2 |
|
Number (comma as decimal) | number_comma_decimal | 50,526 | unspecified number of decimal places |
Phone (North America) | phone | 615-322-2222 |
|
Postal Code (Canada) | postalcode_canada | K1A 0B1 | Format: A0A 0A0 where A is a letter and 0 is a digit |
Social Security Number (U.S.) | ssn | 123-12-1234 | Format: xxx-xx-xxxx |
Time (HH:MM:SS) | time_hh_mm_ss | 31:22:02 |
|
Time (HH:MM) | time | 19:30 | military time |
Time (MM:SS) | time_mm_ss | 31:22 | time in minutes and seconds |
Zipcode (U.S.) | zipcode | 01239 | U.S. Zipcode |
Other Field Options
Mark as Required
In REDCap, attempting to save a form when a required field is empty will remind the user before they leave. The user can still save and exit the form while the field is empty.
In a survey, the participant cannot submit the form or go to the next page until all required fields contain data.
Mark as Identifier
When you indicate a variable as an Identifier, you have the option to “de-identify” your data on data exports. In the Data Export Tool, the identifier variables appear in red and there are de-identification options you can select prior to exporting the data.
Researchers and REBs shall consider whether the information collected is identifiable. This list encompasses the bare minimum of what can be considered identifiers.
In general, the following types of information should always be marked as identifiers in REDCap:
Names
Including initials, signatures
Dates
If collecting full date. Collecting only the year component or age is generally okay.
Date of birth, death, admission, discharge
Contact information
Email addresses, phone numbers, fax numbers
Address information smaller than province/state (ex. city, street, postal code)
Individually identifying data
Social Insurance Number (SIN), Social Security Number (SSN), Personal Health Number (PHN), Health plan beneficiary numbers, Medical Record Numbers (MRNs), biometric identifiers (finger and voice prints), photographic images
This also includes license plates, license numbers, vehicle identifiers (VIN), device identifiers and serial numbers, IP addresses, and URLs
The ‘Check for Identifiers’ give an easy overview of the fields and whether they are enabled as identifiers. Access the page in Project Setup > Design your data collection instruments & enable your surveys
Custom Alignment
By default, fields are made with a Right / Vertical alignment.
Data Dictionary code | Alignment |
|---|---|
RV | Right Vertical |
RH | Right Horizontal |
LV | Left Vertical |
LH | Left Horizontal |
FAQ
- 1 How do I create a set of variables for an unknown number of possible responses for the same question?
- 2 How do I display unknown dates? What’s the best way to format MM-YYYY?
- 3 How are the different date formats exported?
- 4 How are the different date formats imported?
- 5 Can I enter dates without dashes or slashes?
- 6 Can I change date formats if I've already entered data?
- 7 How are dates formatted? Can I change the date format?
- 8 What is the Question Number (surveys only) column in the data dictionary?
- 9 Is it possible to restrict text inputs to a defined length or digit/character combination?
- 10 Can I populate radio buttons, dropdowns, and checkbox field choices using an "if then" statement?
- 11 Can I shorten an instrument by grouping related questions together using a columnar format?
- 12 Is there a question type that is a radio button/checkbox/dropdown with a text box for "Other, specify"?
- 13 Can I set minimum and maximum ranges for certain fields?
- 14 Why can’t I see the different date formats in the Online Designer?
- 15 What is the character limit for a variable name, field label, text typed into a "text box (short text)", and text typed into a "notes box (paragraph text)"?
- 16 Can I upload files to attach to individual subject records?
- 17 Are data from the checkbox (choose all that apply) field types handled differently from other field types when imported or exported?
- 18 How do I indicate “dates” in the data dictionary?
- 19 What to consider when choosing a radio button vs a drop-down?
- 20 How do you calculate e to a power in REDCap?
- 21 Is there an easy way to keep the user from entering future dates on a form?
- 22 Is there a way to hide the “today” button on date fields when it is not applicable to the question?
How do I create a set of variables for an unknown number of possible responses for the same question?
For a question with an unknown number of answers, such as how many medications someone is taking, you may want to display the fields only as they are needed. REDCap currently is not able to dynamically create fields; however, there is a way to use branching logic to approximate this.
If you can estimate the maximum number of fields you will need, you can create that many copies of your field to hide and display as needed using branching logic.
Example 1: If you think 15 is a good maximum, you would create 15 copies of the field. Then, to only show the fields that are needed, you could create a "count" variable. Your branching logic would look like this:
field1: [count]>0
field2: [count]>1
field3: [count]>2
and so on.
If your variable is medications, and the respondent takes 2 medications, you enter 2 in [count] variable, then the med1 and med2 fields appear. If they take 3, you enter that, and meds1 to med3 fields appear.
Example 2a: Another method is to first create the maximum number of fields that you estimate will be needed, as above, and then hide and display each field as the previous field receives data. Using this method will cause each field to show up as needed. Your branching logic would look like this:
field2: [field1] <> "" or [field2] <> ""
field3: [field2] <> "" or [field3] <> ""
field4: [field3] <> "" or [field4] <> ""
and so on.
The fields in this example are text fields. If field1 "does not equal blank" (aka if data is entered for field1), then field2 will display. This example will also retain any given field that happens to have data already.
Example 2b: If you want to only show a field if there is not a previous field that is empty, the branching logic will need to check every previous field:
field2: [field1] <> ""
field3: [field1] <> "" and [field2] <> ""
field4: [field1] <> "" and [field2] <> "" and [field3] <> ""
and so on.
How do I display unknown dates? What’s the best way to format MM-YYYY?
When you set a text field validation type = date, the date entered must be a valid completed date. To include options for unknown or other date formats, you may need to break the date field into multiple fields. For Days and Months, you can create dropdown choices to include numbers (1-31, 1-12) and UNK values. For Year, you can define a text field with validation = number and set a min and max value (ex: 1920 – 2015). The advantage of the multi-field format is that you can include unknown value codes. The disadvantages are that you may need to validate date fields after data entry (i.e. ensure no Feb 31st) and there will be additional formatting steps required to analyze your data fields.
How are the different date formats exported?
The Data Export Tool will only export dates, datetimes, and datetime_seconds in YYYY-MM-DD format. Previously in 3.X-4.0, datetimes were exported as YYYY-MM-DD HH:MM, while dates were exported as MM/DD/YYYY. By exporting only in YYYY-MM-DD format it is more consistent across the date validation field types. If exporting data to a stats package, such as SPSS, SAS, etc., it will still import the same since the syntax code has been modified for the stats package syntax files to accommodate the new YMD format for exported dates. The change in exported date format should not be a problem with regard to opening/viewing data in Excel or stats packages.
How are the different date formats imported?
While the different date formats allow users to enter and view dates in those formats on a survey/form, dates must still only be imported either in YYYY-MM-DD or MM/DD/YYYY format.
Can I enter dates without dashes or slashes?
Date values can be entered using several delimiters (period, dash, slash, or even a lack of delimiter) but will be reformatted to dashes before saving it (e.g. 05.31.09 or 05312009 will automatically be reformatted to 05-31-2009 for MM-DD-YYYY format).
Can I change date formats if I've already entered data?
Any date fields that already exist in a REDCap project can be easily converted to other formats without affecting the stored data value. After altering the format of the existing date fields, dates stored in the project will display in the new date format when viewed on the survey/form. Therefore, you change the date format of a field without compromising the stored data.
How are dates formatted? Can I change the date format?
Dates can be formatted as mm-dd-yyyy, dd-mm-yyyy, and yyyy-mm-dd by using the text field > validation. These formats cannot be modified. It is recommended to always use the field label or field note to specify the required date format.
What is the Question Number (surveys only) column in the data dictionary?
For surveys, you can use this column to enter the number of survey questions for screen display.
Is it possible to restrict text inputs to a defined length or digit/character combination?
You can restrict text inputs by using text/note field > action tags. You can set a specific word/character limit with the tags @WORDLIMIT or @CHARLIMIT. Only one of these tags can be used on a single field at a given time.
Can I populate radio buttons, dropdowns, and checkbox field choices using an "if then" statement?
There is currently no way of populating field choices dynamically. You can create multiple fields and response option lists and hide or display them using branching logic.
Can I shorten an instrument by grouping related questions together using a columnar format?
Yes. You can use field embedding within a descriptive text field to shorten the instrument and group-related questions.
Is there a question type that is a radio button/checkbox/dropdown with a text box for "Other, specify"?
No, this specific question type is not available. You can add a text field after the question and use branching logic so that if "Other" is selected, a text box appears to capture the data.
Can I set minimum and maximum ranges for certain fields?
If validation is employed for text fields, min, and max values may be utilized. Min, max, neither or both can be used for each individual field. The following text validation types may utilize min and/or max values:
DATE_YMD |
DATE_MDY |
DATE_DMY |
TIME |
DATETIME_YMD |
DATETIME_MDY |
DATETIME_DMY |
DATETIME_SECONDS_YMD |
DATETIME_SECONDS_MDY |
DATETIME_SECONDS_DMY |
NUMBER |
INTEGER |
Why can’t I see the different date formats in the Online Designer?
New validation types that are not automatically available will need to be enabled by your REDCap Administrator. Once enabled, they'll appear in the text validation drop-down list in the Online Designer. All formats are available via the Data Dictionary.
What is the character limit for a variable name, field label, text typed into a "text box (short text)", and text typed into a "notes box (paragraph text)"?
The maximum number of characters is:
Variable name: *Recommended: <26, Max: 100
Field label: ~65,000
Text typed into a "text box" field: ~65,000
Text typed into a "notes box" field: ~65,000
*Most stats packages (SAS, STATA...) will truncate variable names to a max of 26 characters.
Can I upload files to attach to individual subject records?
Yes, you can upload documents for individual records by using a file upload field. To create a new document upload field in the Data Dictionary for any given REDCap project, set the field Type = ‘file’. You may add as many 'file' fields as needed to your data collection instruments. Documents can be uploaded and downloaded by navigating to the record’s data entry page and clicking the file link. A document can be deleted at any time, and there is no limit to how many times the document can be replaced by uploading another file to that record’s file upload field.
Contact your REDCap Administrator to confirm if this field type is available and what the maximum upload file size is at your institution.
Are data from the checkbox (choose all that apply) field types handled differently from other field types when imported or exported?
Yes. When your data are exported, each option from a checkbox field becomes a separate variable coded 1 or 0 to reflect whether it is checked or unchecked. By default, each option is pre-coded 0, so even if you have not yet collected any data, you will see 0's for each checkbox option. The variable names will be the name of the field followed by the option number. So, for example, if you have a field coded as follows:
Race
1, Caucasian
2, African American
3, Asian
4, Other
In your exported dataset, you will have four variables representing the field Race that will be set as 0 by default, coded 1 if the option was checked for a record. The variable names will consist of the field name. three underscores, and the choice value:
race___1
race___2
race___3
race___4
Notes:
when you import data into a checkbox field, you must code it based on the same model
negative values can be used as the raw coded values for checkbox fields. Due to certain limitations, negative values will not work when importing values using the Data Import Tool, API and cause problems when exporting data into a statistical analysis package. The workaround is that negative signs are replaced by an underscore in the export/import-specific version of the variable name (e.g., for a checkbox named "race", its choices "2" and "-2" would export as the fields
race___2
race____2
A checkbox field can be thought of as a series of yes/no questions in one field. Therefore, a yes (check) is coded as 1 and a no (uncheck) is coded as 0. An unchecked response on a checkbox field is still regarded as an answer and is not considered missing.
How do I indicate “dates” in the data dictionary?
Text Validation Types: Use for text field data validation
Format | Example |
DATE_DMY | 16-02-2011 |
DATE_MDY | 02-16-2011 |
DATE_YMD | 2011-02-16 |
DATETIME_DMY | 16-02-2011 17:45 |
DATETIME_MDY | 02-16-2011 17:45 |
DATETIME_YMD | 2011-02-16 17:45 |
DATETIME_SECONDS_DMY | 16-02-2011 17:45:23 |
DATETIME_SECONDS_MDY | 02-16-2011 17:45:23 |
DATETIME_SECONDS_YMD | 2011-02-16 17:45:23 |
What to consider when choosing a radio button vs a drop-down?
Dropdown:
Ability to use autocomplete
Less space on forms; use when you have limited space
Radio Button:
Good when you need your choices visible
A good option for minimal response options
Available with the matrix options when building forms
How do you calculate e to a power in REDCap?
REDCap doesn’t have a specific function for e, so you will need to use the numerical equivalent to e and calculate from that. For example:
(2.718281828) ^ ([field_1]). Both sides of the exponent need to be encased in parentheses.
Is there an easy way to keep the user from entering future dates on a form?
If you have another field validated as a date and with the @TODAY (and possibly the @HIDDEN or @READONLY), then you could use a Data Quality rule with the "Execute in real time on data entry forms" checkbox checked. The DQ rule real-time execution won't work on a survey, so on a survey, you would need to settle for a descriptive text field that displays an error message if the date is greater than your date field with @TODAY in it.
Is there a way to hide the “today” button on date fields when it is not applicable to the question?
Yes. You can turn it off on the project level by going to “Enable optional modules and customizations” on the Project Setup page. Go to “Additional Customizations” and uncheck “Display the Today/Now button for all date and time fields on forms/surveys?”
To turn it off on the field level, you can use the actin tag @HIDEBUTTON on that field.