Text Field
The box where users type names, emails, passwords and messages. Learn its parts, the keyboards it opens, when errors should appear, and the inputs that break it.
Signing up for a food delivery app, searching for a flight, typing a card number, leaving a note for the courier: almost every journey in an app goes through a text fieldText fieldAn input where the user types text, like a name, email, password or search query.Open in glossary →. It’s the most common input on the planet, and because users can type anything into it, it’s also one of the richest places to find bugs.
In this lesson you’ll learn what a good text field looks like on each platform, and how testers break the bad ones. For whole forms (validation timing, error summaries, server errors and real-world data), see Forms and Validation.
What is a text field?
A text field is a box that accepts free text from the keyboard. It can be a single line (name, email, promo code) or several lines (a review, delivery instructions). Unlike a dropdown or a toggle, the user isn’t choosing from options: they can enter any character, in any amount, in any language. That freedom is exactly what makes it risky.
You’ll usually see text fields used for:
- Personal data: name, email, phone number, address.
- Secrets: passwords, PINs, one-time codes.
- Search: products, recipes, destinations.
- Free-form content: reviews, chat messages, notes for the courier.
- Numbers that aren’t really “numbers”: postcode, card number, quantity, amount.
Anatomy
We'll send your receipt here.
Display name
Password
Use at least 8 characters.
- 1
Label
Tells the user what to enter. Always visible, even after typing.
- 2
Input area (container)
The box you tap or click. Holds the value the user types.
- 3
Placeholder
Optional example text inside an empty field. Disappears when you type, so it is not a label.
- 4
Helper text
Extra guidance below the field: format, why we need it, if it is optional.
- 5
Error message
Replaces the helper text when the value is wrong. Says what to fix.
- 6
Character counter
Shows how many characters are used out of the limit.
- 7
Leading / trailing icon
A hint icon (mail) or an action icon (show password).
- 8
Clear button
Empties the field in one tap. Shown only when there is text.
How it differs from similar components
| Component | What the user does | Typical use |
|---|---|---|
| Text field | Types a short, single line | Name, email, promo code |
| Text area (multiline field) | Types several lines | Reviews, messages, delivery notes |
| Search field | Types to find something, usually with instant results | Product search, filtering a list |
| Dropdown / select | Picks one value from a fixed list | Country, size, sort order |
| Combo box | Types to filter a list, then picks | Choosing a city from thousands |
| Date picker | Picks a date from a calendar or wheel | Birthday, booking dates |
Dev note
iOS calls it a text field (UITextField, or TextField in SwiftUI) and a text view for multiline. Android developers say EditText, while Material Design says text field. On the web it’s an <input> element (or <textarea> for multiline). In bug reports, use the name your team uses.
Designs & variants
Each platform has its own look. The parts are the same, but the risks differ: a floating label can overlap autofilled text, a left-hand label can truncate, a field with no visible label can confuse everyone.
Every field below is live: click, type, clear, and tab through them. Use the switch to compare light and dark.
Delivery address
Grouped form
iOSRows inside a rounded group, like Settings. The label sits on the left, so long labels and large text are the risk here.
Filled text field
Android · Material 3Tinted box with an underline. The label floats up when you focus or type. Watch for labels overlapping autofilled text.
Outlined text field
Android · Material 3The floating label cuts into the border. A leading icon hints at the content; the clear button appears once you type.
Label above
WebThe most common web pattern. The label never moves, which makes it the easiest to read and to test.
Password with show/hide
AllThe eye button reveals the password. Check it toggles both ways and that the value is never lost when you switch.
Search field
iOSNo visible label, so the placeholder and the icon do the job. Screen readers still need a name ('Search').
Multiline with counter
Android · Material 3For longer text. The counter counts characters the way people see them. Go over the limit to see the error.
Disabled and error states
WebDisabled fields are dimmed and can't be focused. An error turns the border red and says how to fix the value.
Types and mobile keyboards
On a phone, the field’s type decides which keyboard appears. A missing or wrong type is a real, reportable bug: imagine typing an email on a keyboard with no @ key, or a postcode on a full letter keyboard.
⌨️ One field, many keyboards
On a phone, the input type decides which keyboard opens. Pick a field type and see what the user gets.
- Web (HTML)
- type="email" autocomplete="email"
- iOS keyboard type
- .emailAddress, autocapitalization off
- Android inputType
- textEmailAddress
What to check
The @ and . keys are visible, the first letter is NOT capitalized, and autocorrect does not "fix" the address.
States
A text field goes through several UI statesUI stateHow a component looks and behaves in a given situation: default, hover, pressed, focused, disabled, loading, error.Open in glossary →. Each one needs to look different and behave correctly.
| State | What it looks like | What to check |
|---|---|---|
| Empty | Label and maybe a placeholder | The placeholder is an example, not the only label |
| Focused | Highlighted border, cursor blinking, keyboard open | Focus is clearly visible (not only a color change) |
| Filled | Shows the value | Long values scroll or wrap; nothing is cut off on save |
| Disabled | Dimmed, can’t be focused | Can’t be edited by tapping, Tab key, or autofill. See disabled stateDisabled stateA component that is visible but can't be used right now, usually shown greyed out.Open in glossary → |
| Read-only | Looks like text, can be selected and copied | Can’t be changed, but CAN be copied and read by screen readers |
| Error | Red border and a message | The message explains how to fix it, and disappears once fixed |
| Loading | Small spinner, e.g. “Checking username…” | Typing fast doesn’t show the result for an old value |
When should errors appear?
Input validationInput validationChecking that what the user typed is acceptable before the app uses it.Open in glossary → checks the value. The tricky part is timing. Show the error too early and you nag the user mid-sentence; show it too late and they discover all problems at the end. Try the three common strategies:
⏱️ When should the error appear?
Pick a strategy, then type an address slowly, e.g. "anna@test.com". Try leaving the field half-done, too.
Sign in to FreshCart
We'll email you a one-time code.
0
times an error popped up while typing
—
no error shown
On blur
No error until you leave the field. After that, the field re-checks as you type, so the error disappears the moment the value is fixed. This "late to complain, quick to forgive" approach is the usual recommendation.
Autofill and autocomplete
Phones and browsers can fill in names, addresses, passwords and one-time codes for the user. It only works if each field tells the system what it contains.
| Field | Web autocomplete | iOS textContentType | Android autofillHints |
|---|---|---|---|
| Full name | name | .name | personName |
email | .emailAddress | emailAddress | |
| Phone | tel | .telephoneNumber | phone |
| Street address | street-address | .fullStreetAddress | postalAddress |
| Postcode | postal-code | .postalCode | postalCode |
| New password | new-password | .newPassword | newPassword |
| SMS code | one-time-code | .oneTimeCode | smsOTPCode |
When testing autofill, check that values land in the right fields (no surname in the city field), that autofilled values pass validation (autofill sometimes adds a trailing space), and that floating labels don’t overlap the filled text.
When to use it
A text field is the right choice when:
- The answer is truly open: names, addresses, messages, search terms.
- There are too many possible values to list (every email address in the world).
- Users know the answer and typing is faster than scrolling (a postcode, a promo code).
Good and bad uses
A visible label above every field
Full name
Anna KovačPhone
+385 91 234 5678The label stays while you type, so you always know what the field is for.
Placeholder used as the label
Halfway through typing, which field is this? The hint vanished with the first letter. Placeholders also tend to have low contrast and are often skipped by screen readers.
Free text for free answers
Every answer is different, so a text field fits.
Free text for a fixed list
A typo and a trailing space, and now shipping can’t find the country. A known list belongs in a dropdown or a combo box.
One field that accepts any format
Paste works, spaces are fine, and the app removes them before checking.
Split into boxes
Card number
Pasting the number fills only the first box, autofill breaks, and deleting jumps between boxes in surprising ways.
Common bugs
These are the text field bugs testers report again and again.
| # | Bug | What you see | Typical severity |
|---|---|---|---|
| 1 | Spaces break validation | A valid email with a trailing space (from autofill or copy-paste) is rejected | High |
| 2 | Error never clears | You fix the value, but the red message stays until you submit again | Medium |
| 3 | Silent truncation | A phone number or address is cut off at a hidden limit, with no message | High |
| 4 | Wrong character count | The counter says “2/20” for one emoji, or a limit cuts an emoji in half | Low–Medium |
| 5 | “Numeric” field accepts letters | A postcode, quantity or year accepts 19ab and saves it | Medium |
| 6 | Wrong keyboard | Email opens a keyboard with no @; a postcode opens letters | Medium |
| 7 | Valid input rejected | O'Brien, Đurđa, anna+shop@test.com or a 2-letter surname is refused | High |
| 8 | Input rendered as HTML | Typing <b>Anna</b> shows Anna in bold somewhere. A sign of an XSSCross-site scripting (XSS)An attack where text a user enters is run as code in other people's browsers.Open in glossary → hole | Critical |
| 9 | Broken characters | Kovač is saved or shown as KovaÄ or Kova? (an encoding bug) | Medium–High |
| 10 | Paste blocked | Paste does nothing in password or “confirm email” fields | Medium |
| 11 | Data lost | Text disappears after rotating, switching apps, or a failed submit | High |
| 12 | Keyboard hides the field | The field (or its error) is behind the on-screen keyboard and can’t be seen | Medium |
Stress-test it
This is where testers earn their money. Real users paste, autofill, use emoji and have names developers never imagined. Each input below is a classic negative testNegative testingTesting with invalid or unexpected input to check the software handles it gracefully.Open in glossary → or edge caseEdge caseAn unusual situation at the extreme of what the software should handle.Open in glossary →:
🧪 Input torture playground
Testers feed fields the inputs developers forget. Pick a test input (it is pasted into the field) or type your own, and see how a well-built field handles it.
Checkout details
Preview on next screen
Nothing valid to show yet- Typed / pasted
- (nothing)
- Length
- 0 characters
- Result
- Waiting for input…
Why testers try this
Pick a test input above. Each one targets a different kind of bug.
Find the bug
The plant shop sign-up below has six bugs. Test it like a pro:
- Type valid data first, then invalid data.
- Leave fields half-done and come back to fix them.
- Use emoji, spaces and international formats.
- Watch the keyboard, the profile preview and the network log.
🐞 Bug hunt: Bloom sign-up
This demo has 6 hidden bugs. Explore it like a tester, then check your findings.
Create account
Profile preview
Hi, there!
Tip: the keyboard shows which type each field opens.
Network log
Create an account to see the request body…
- 1
Hint: Leave the email field with a typo, then go back and fix it.
- 2
Hint: Keyboards and autofill often add a space after the last word.
- 3
Hint: Put emoji in the display name and watch the counter.
- 4
Hint: Type the phone number in the format shown in the placeholder.
- 5
Hint: Look at the keyboard for Year of birth, then try typing letters.
- 6
Hint: Type a display name like <b>Anna</b> and watch the profile preview.
How to test it
Checklist
Text field test checklist
0 of 14 checked
Example test cases
TC-TXT-001Valid email is acceptedpositivehigh
Steps
- Open the Sign-up screen
- Enter "anna@test.com" in Email
- Fill other fields with valid data
- Tap "Create account"
Expected result
No error is shown and the account is created with email "anna@test.com".
TC-TXT-002Email with surrounding spaces is trimmededgehigh
Steps
- Enter " anna@test.com " in Email (two spaces before and after)
- Move to the next field
- Tap "Create account"
Expected result
No error is shown. The saved / sent value is "anna@test.com" without spaces.
TC-TXT-003Error disappears once the value is fixednegativemedium
Steps
- Enter "anna@test" in Email
- Move to the next field
- Go back and change the value to "anna@test.com"
Expected result
An error appears after step 2 and disappears as soon as the value becomes valid in step 3, without submitting.
TC-TXT-004Name accepts apostrophes and local letterspositivehigh
Steps
- Enter "Seán O'Brien" in Full name and save
- Repeat with "Đurđica Šćepanović" and "Јована Петровић"
- Reopen the profile
Expected result
All names are accepted and displayed exactly as entered on every screen and in emails.
TC-TXT-005Maximum length boundaryedgemedium
Preconditions
- Display name limit is 30 characters
Steps
- Enter exactly 30 characters
- Enter 31 characters (type and paste)
- Enter 29 letters plus one emoji
Test data
30 chars: "Anna-Marie Kovač-Horvat Zagreb"
Expected result
30 characters are accepted. 31 shows a clear limit message and nothing is cut silently. 29 letters + 1 emoji counts as 30.
TC-TXT-006HTML is shown as plain textnegativehigh
Steps
- Enter "<b>Anna</b>" as Display name
- Save the profile
- View the name on the profile, in a review and in the order email
Expected result
The literal text "<b>Anna</b>" is shown everywhere. Nothing turns bold and no script runs.
TC-TXT-007Numeric field rejects pasted lettersnegativemedium
Steps
- Focus Year of birth and check the keyboard
- Paste "19ab"
- Tap "Create account"
Expected result
A number pad opens. The letters are rejected or removed, and an error explains the expected format (e.g. "Enter a year like 1994").
TC-TXT-008Password show/hide keeps the valuepositivelow
Steps
- Type "Secret123!" in Password
- Tap the eye icon
- Tap it again
- Add "4" at the end
Expected result
The password is shown in plain text after step 2 and masked after step 3. The final value is "Secret123!4".
TC-TXT-009Typed text survives a failed submitnegativemedium
Preconditions
- Device is offline
Steps
- Fill in all fields
- Tap "Create account"
- Dismiss the "No connection" error
Expected result
All entered values (except possibly the password, if the team decided so) are still in the fields.
Tip: click a test case to expand it.
Accessibility
Text fields are where many users with disabilities get stuck. Check these:
- A real label. Every field needs a label connected to it in code. A placeholder doesn’t count. Test it: tapping the label on the web should focus the field.
Dev note
<label for>on the web,accessibilityLabelon iOS,labelForor a Material label on Android. - Screen readers (VoiceOver / TalkBackScreen readerSoftware that reads the screen aloud for blind and low-vision users, like VoiceOver or TalkBack.Open in glossary →) should announce the label, the field type (“text field”, “secure text field”), the current value, any hint and the error message.
Dev note
On the web, errors are linked witharia-describedbyand marked witharia-invalid="true". - Errors aren’t color only. A red border isn’t enough: there must be text, ideally with an icon.
- Contrast: text, label and placeholder need at least 4.5:1 against the background; the field’s border at least 3:1 (WCAGWCAGThe Web Content Accessibility Guidelines, the main international standard for accessibility.Open in glossary →).
- Big text: at the largest Dynamic TypeDynamic TypeThe phone setting that lets users make text bigger or smaller across apps.Open in glossary → sizes, labels and values must stay readable, not clipped.
- Touch targetsTouch targetThe area of the screen that responds to a tap, which should be large enough for a finger.Open in glossary →: the field and its icon buttons (clear, show password) should be at least 44×44 pt on iOS and 48×48 dp on Android. On the web, WCAG 2.5.8 (AA) asks for at least 24×24 CSS px; 44×44 px (2.5.5, AAA) is the comfortable target.
- Autocomplete attributes help users with motor or memory difficulties fill forms without typing. On the web that’s a WCAG requirement for fields about the user, too (1.3.5 Identify Input Purpose, Level AA).
Mobile vs web
Dev note
UITextField / UITextView (UIKit), TextField / TextEditor (SwiftUI).- Keyboard type, auto-capitalization, autocorrect and the autofill content type are set per field. Check all four.
Dev note
The autofill content type istextContentType. - Clear button (“x”) and secure entry (dots) are built in.
- The keyboard can cover the field: scroll the form and check the focused field is visible.
- Test Dynamic Type, dark mode and the Passwords autofill bar.
Dev note
EditText; with Material Design, TextInputLayout (filled or outlined) or TextField in Jetpack Compose.- Test the keyboard with Gboard and Samsung Keyboard, because they behave differently.
Dev note
TheinputTypecontrols the keyboard. - Floating labels: check they don’t overlap autofilled text or the prefix/suffix.
- Check what happens after rotation and after the app is killed in the background: the text should survive.
- Test with font scale, display size and TalkBack.
Dev note
<input> with a type (email, tel, password, number, url, search) or <textarea>.type="number"has quirks (it acceptse, and in Chromium browsers the mouse wheel changes a focused value; see Stepper), so many teams useinputmode="numeric"instead. Know which one your app uses.- Use DevTools to check the
label,autocomplete,aria-invalidandaria-describedbyattributes. - Test browser autofill in Chrome, Safari and Firefox, plus password managers.
- Test on a phone browser too: the right keyboard depends on
typeandinputmode.
Check your understanding
Quick quiz
0/5 answered · 0 correct
1.Why is a placeholder NOT a replacement for a label?
2.A valid email with a trailing space is rejected. What is the most likely cause?
3.The quantity field shows a number pad. Do you still need to test letters?
4.You type <b>Anna</b> as your name and the confirmation screen shows "Anna" in bold. How serious is this?
5.Which validation timing is generally recommended for an email field?
Key takeaways
- A text field accepts anything, so test far beyond the happy path: empty, spaces, long, emoji, accented letters, apostrophes, HTML and pasted text.
- Every field needs a visible label. A placeholder is an example, not a label.
- The input type decides the mobile keyboard and autofill, but it’s not validation.
- Errors should appear at a sensible time, explain how to fix the value, and disappear once it’s fixed.
- The classic bugs: untrimmed spaces, stale errors, silent truncation, wrong counts with emoji, wrong keyboards, valid names rejected, and input rendered as HTML.
Finished this page?Nice work, this page is complete!
Mark it as done to track your progress. It's saved in this browser, no account needed.
Its review cards are now in Bites ⚡