Web Form Testing

Form Validation Test Cases That Keep UI and API Rules Aligned

An error message is not proof that form validation works.

  1. Valid user data is accepted.
  2. Invalid data is rejected by the browser where useful.
  3. The same invalid data is rejected by the server.
  4. Client and server rules do not contradict each other.
  5. Normalization does not silently change the meaning of the value.
  6. Cross-field and conditional rules use the complete form state.
  7. Errors identify the problem and help the user correct it.
  8. Corrected data can be submitted without duplicate processing.

This guide contains 52 form validation test cases covering required fields, boundaries, formats, Unicode, dependent rules, client-server parity, accessible errors and recovery after validation failure.

WrightTest Team 52 test cases
Form validation testing workflow comparing browser rules, API enforcement, normalized data, accessible errors, and successful correction
A complete validation test proves one documented rule across the browser, API and correction journey.

The Minimum Form Validation Smoke Test

When release time is limited, start with these ten cases.

The minimum form validation smoke test
IDTestFailure it can reveal
FV-01Submit the form with one complete valid datasetValid users are incorrectly blocked
FV-03Submit all required fields emptyPresence validation is missing
FV-05Submit whitespace in a required text fieldBlank values are treated as meaningful data
FV-09Enter one value below the minimum lengthLower boundary is enforced incorrectly
FV-12Enter one value above the maximum lengthUpper boundary is enforced incorrectly
FV-20Submit an invalid structured formatFormat validation is missing
FV-30Violate a cross-field relationshipIndividual fields pass while the complete form is invalid
FV-37Bypass browser validation and send an invalid requestThe server trusts the browser
FV-41Compare the same value through UI and APIValidation rules contradict each other
FV-48Correct one invalid field and resubmitData is lost or the form cannot recover

The smoke set checks the central validation contract. It does not replace field-specific security, accessibility, localization or business-rule coverage.

Define the Validation Contract Before Writing Cases

A form field should not be described only as "valid" or "invalid." For each field or field relationship, define the rule that every layer should enforce.

Validation contract elements
Contract elementQuestion
PresenceIs the value required, optional or conditionally required?
TypeIs it text, number, date, identifier, selection, file or structured object?
FormatWhich syntactic forms are accepted?
Length or rangeWhat are the exact inclusive and exclusive limits?
NormalizationAre spaces, case, separators or Unicode forms transformed?
Semantic ruleIs the value meaningful in the current business context?
Cross-field ruleDoes validity depend on another field?
Server ruleWhat must still be enforced when the browser is bypassed?
Error behaviorWhat message, focus and preserved state should the user receive?
Stored valueWhich exact representation should reach the backend?

Example validation contract

Example validation contract
FieldClient ruleServer ruleNormalizationExpected error
Display nameRequired; 2-80 charactersSame length and permitted-character policyTrim outer spacesEnter a name between 2 and 80 characters
EmailRequired; supported email syntaxSame syntax plus application identity policyTrim outer spaces; defined case policyEnter a valid email address
QuantityInteger from 1 to 100Integer from 1 to 100No silent decimal roundingEnter a whole number from 1 to 100
Start and end dateBoth are valid datesStart must not be after endUse defined timezone and calendarEnd date must be on or after start date
VAT numberRequired only for business accountsCountry-specific semantic ruleRemove allowed separators only if documentedEnter a valid VAT number for the selected country
Validation contract showing presence, format, boundaries, normalization, semantic rules, UI feedback, API enforcement, and stored representation
A written contract prevents the current UI behavior from becoming an accidental business rule.

Separate Validation from Normalization

Validation answers whether a value is allowed. Normalization answers which equivalent representation should be stored or compared.

"  Maria  " -> "Maria"
"+31 20 123 4567" -> normalized phone representation
"[email protected]" -> identity-policy representation
Unicode composed form -> selected canonical form

For every normalized field, test that the application accepts the supported input representation, stores the documented representation and does not change the user's intended meaning.

Use Systematic Data Selection Instead of Random Invalid Values

A strong validation suite needs small datasets selected from the rule, not hundreds of arbitrary strings.

Length boundary template

m - 1 -> rejected
m     -> accepted
n     -> accepted
n + 1 -> rejected

Numeric boundary template

9
10
11
99
100
101

Cross-field truth table

Start/end-date truth table
Start dateEnd dateExpected
ValidLaterAccept
ValidSameAccept if equality is allowed
ValidEarlierReject
MissingPresentApply presence policy
PresentMissingApply presence policy
InvalidValidReport the invalid field before the relationship

Conditional-field table

Conditional company-number rule
Account typeCompany numberExpected
PersonalEmptyAccept
PersonalPresentIgnore, accept or reject according to policy
BusinessEmptyReject
BusinessValidAccept
BusinessInvalidReject with field-specific guidance
Business changed to PersonalPrevious value remainsClear or retain according to documented behavior
Systematic form validation data selection using minimum, maximum, adjacent boundaries, truth tables, and conditional-field combinations
Boundary values and truth tables keep validation cases small, traceable and tied to the documented rule.

Required and Optional Field Test Cases

Required and optional field cases
IDScenarioExpected resultEvidence
FV-01Submit all required fields with a valid datasetValidation passes and the form reaches the intended submission stepBrowser result and request
FV-02Leave every optional field emptyThe form remains valid and no optional field produces an errorBrowser result and payload
FV-03Submit with all required fields emptySubmission is blocked and every missing requirement is identifiedError summary, field errors and absence of request
FV-04Omit one required field at a timeOnly the relevant missing-field rule failsField state and error message
FV-05Enter spaces, tabs or line breaks into a required text fieldThe documented blank and trimming policy is applied; meaningless whitespace is not stored as valid contentVisible result and server response
FV-06Leave a required checkbox, radio group or select option unchosenSubmission is blocked and the complete group is identified correctlyGroup error and focus behavior
FV-07Submit a field that is optional in the UI but required by the APIThe mismatch is exposed; the user does not receive an unexplained generic failureUI state, request and server response
FV-08Interact with a required field without entering dataValidation appears at the intended event without showing an error before the user has a reasonable chance to respondEvent sequence and visual state

A required indicator must be visible and programmatically associated with the field. Do not rely only on color or an unexplained asterisk.

Length, Range, Number and Date Test Cases

Length, range, number and date cases
IDScenarioExpected resultEvidence
FV-09Enter a value one unit below the minimum lengthThe value is rejected with exact lower-bound guidanceField state and server response
FV-10Enter a value exactly at the minimum lengthThe value is acceptedBrowser and API result
FV-11Enter a value exactly at the maximum lengthThe value is accepted without truncationPayload and stored value
FV-12Enter or paste a value one unit above the maximum lengthThe application rejects or prevents the extra input according to policy; it does not silently store a different valueUI, payload and stored value
FV-13Enter a number immediately below the minimumThe value is rejectedValidation state and response
FV-14Enter a number exactly at both supported boundariesInclusive boundaries are acceptedRequest and response
FV-15Enter a number immediately above the maximumThe value is rejectedValidation state and response
FV-16Enter a decimal, excessive precision or value that violates stepThe exact numeric contract is applied; the value is not silently rounded unless documentedPayload and stored value
FV-17Enter an impossible calendar value or unsupported dateThe value is rejected consistently across input methods and direct server requestsBrowser and API result
FV-18Enter dates exactly at and immediately outside the allowed rangeDate boundaries use the documented timezone and inclusivity rulesRequest, server result and stored date

Native constraints such as required, minlength, maxlength, min, max, step, type and pattern improve browser feedback but do not replace server enforcement.

Format, Whitespace and Unicode Test Cases

Format, whitespace and Unicode cases
IDScenarioExpected resultEvidence
FV-19Submit a valid value in every officially supported formatEvery supported representation is acceptedBrowser and API results
FV-20Submit a value with invalid syntaxThe field is rejected with guidance describing the required formatError message and server response
FV-21Enter leading and trailing spaces around an otherwise valid valueOuter whitespace follows the normalization contract consistently in UI and APIPayload and stored value
FV-22Enter internal spaces or separatorsThe application preserves, removes or rejects them according to the field-specific ruleUI result and stored representation
FV-23Enter valid non-Latin charactersThe value is accepted where the business rule permits international textBrowser, API and stored value
FV-24Enter a valid name containing an apostrophe, hyphen or diacriticLegitimate punctuation and letters are not rejected by a simplistic character filterBrowser and server result
FV-25Enter visually equivalent Unicode sequences in composed and decomposed formsComparison, uniqueness and storage follow the documented Unicode normalization policyAPI response and stored representation
FV-26Enter emoji or symbols into free-form textThe value follows the documented policy without corrupting length calculations or storageCharacter count and stored value
FV-27Enter a line break, tab or non-breaking spaceInvisible characters are handled predictably and do not create a misleading valid valuePayload inspection and server response
FV-28Submit a very long value through a direct requestThe server rejects it gracefully without excessive processing, truncation or an unhandled errorResponse, logs and unchanged data

Do Not Mistake Strictness for Correctness

The values O'Connor, Anne-Marie, [email protected], 020 1234 5678 and localized numbers are not automatically invalid. Their validity depends on field purpose, supported locales, identity policy, normalization rules and downstream system requirements.

Treating names as ASCII letters only

Human names are not reliable identifiers and do not follow one global character pattern.

Treating phone numbers as numeric values

Phone numbers can contain leading zeros, country prefixes, spaces and separators. They are normally identifiers represented as text.

Rejecting plus-addressed email without a product rule

An application can define an identity policy, but it should not reject a supported address merely because a simplistic pattern does not anticipate it.

Removing punctuation from free-form text

Filtering punctuation is not a primary defence against injection. Output encoding, parameterized queries and context-specific controls are still required.

Parsing localized numbers without an explicit locale

1,500 and 1.500 can mean different values. The displayed format, parser and stored representation must agree.

Cross-Field, Conditional and Dynamic Validation Test Cases

Cross-field, conditional and dynamic cases
IDScenarioExpected resultEvidence
FV-29Enter valid individual values that violate a relationship such as password confirmationThe relationship error is shown and submission is blockedForm state and server response
FV-30Enter a start value that exceeds the end valueSemantic validation rejects the complete form even though both fields are syntactically validRelationship error and API result
FV-31Change a controlling value such as country after entering a dependent value such as postal codeThe dependent field is revalidated using the new ruleField state and submission result
FV-32Trigger a condition that makes another field requiredThe field becomes visibly and programmatically required before submissionDOM state and error behavior
FV-33Hide a previously required conditional fieldThe hidden field no longer blocks submission unless the business rule deliberately retains itForm validity and payload
FV-34Enter data in a conditional field and then disable its conditionThe value is cleared, retained or excluded according to the documented data policyUI state and request payload
FV-35Move through a multi-step form with valid fields on one step and an invalid cross-step relationshipValidation occurs at the correct point and returns the user to the relevant field without losing completed stepsNavigation, errors and preserved data
FV-36Submit syntactically valid data that violates a server-known business ruleThe server rejects it and the UI maps the response to a useful field or form-level errorServer response and rendered error

Cross-field validation is different from validating two fields separately. Every individual value can satisfy its format while the combined state remains invalid.

Client, Server and API Parity Test Cases

Client-side validation provides immediate feedback, but every untrusted request must still be validated by the server.

Client, server and API parity cases
IDScenarioExpected resultEvidence
FV-37Remove required, pattern, min, max or related constraints and submitServer-side validation rejects the invalid requestServer response and unchanged data
FV-38Disable or bypass JavaScript validationInvalid data still cannot enter the workflowRequest and server response
FV-39Send invalid data directly to the APIThe API applies the documented validation contractStatus, error body and stored-data check
FV-40Send unexpected, missing or extra fieldsThe server applies the request schema instead of trusting arbitrary propertiesResponse and stored object
FV-41Send the same boundary value through browser and APIBoth layers reach the same acceptance decisionUI result and API result
FV-42Submit a value accepted by the UI but rejected by the serverThe mismatch is visible, mapped to the correct field and recorded as a contract defectClient state and response
FV-43Submit a value rejected by the UI but accepted by the serverThe false-negative client rule is identified; valid users are not permanently blocked by stale browser logicDirect API result and UI result
FV-44Deploy client and server validation changes separatelyVersion differences fail safely and produce useful errors rather than silent corruption or an unrecoverable formResults before, during and after deployment

Validation parity matrix

Validation parity matrix
RuleUI resultAPI resultExpected
Required field missingRejectRejectMatch
Minimum boundaryAcceptAcceptMatch
Below minimumRejectRejectMatch
Supported Unicode nameAcceptAcceptMatch
Invalid cross-field relationshipRejectRejectMatch
Server-only business conflictMay submit requestReject and map errorDeliberate difference
Stale reference dataMay pass local checkReject with recoverable responseDeliberate difference

Client and server do not need identical timing or identical code. They need a compatible acceptance contract, with the server making the authoritative decision.

Error Message, Accessibility and Recovery Test Cases

Errors, accessibility and recovery cases
IDScenarioExpected resultEvidence
FV-45Submit several invalid fields togetherEvery relevant error is available without one error hiding anotherError summary and field messages
FV-46Submit an invalid form using the keyboardFocus moves according to the documented pattern and every problem remains reachableFocus sequence and keyboard walkthrough
FV-47Inspect error relationships with assistive technologyErrors are associated with their controls and dynamic status changes are announced appropriatelyAccessibility tree and screen-reader check
FV-48Correct one invalid fieldThat field error clears at the intended event without clearing unrelated unresolved errorsField and summary state
FV-49Receive a server-side validation responseValid non-sensitive values remain populated; sensitive values follow the documented retention policyRedisplayed form state
FV-50Receive a form-level business-rule errorThe user receives actionable guidance and can edit the relevant fields without restarting the entire flowVisible error and preserved state
FV-51Correct all errors and resubmitOne successful request is processed; failed attempts do not create duplicate recordsRequest and record counts
FV-52Use mobile input, paste, autofill, password manager or localized inputValidation reacts consistently to supported input methods and does not depend only on keyboard eventsMobile/browser runs and final payload

Errors should identify the affected control, explain the problem in text, remain discoverable without relying only on color and preserve non-sensitive valid data after server-side redisplay.

The Most Important Form Validation Failure Patterns

Form validation failures caused by UI and API rule drift, normalization order, hidden fields, lost input, and unmapped server errors
The costly validation bugs usually happen where browser rules, API rules and correction behavior drift apart.

The browser rejects a value that the API accepts

An outdated pattern, duplicated rule or simplified frontend check blocks legitimate data even though the server contract permits it.

The browser accepts a value that the API rejects

The rejection must map back to a useful field or form-level error without losing data.

One layer trims the value while another validates the raw value

Define whether normalization occurs before validation, after validation, only for storage or only for comparison, then apply that order consistently.

A hidden field continues blocking submission

Check visibility, disabled state, required state, custom validity, request inclusion and retained value when conditions change.

Correcting an error destroys valid data

Users should not need to reconstruct the entire form or re-enter all non-sensitive values after one validation error.

The server returns an error the UI cannot locate

Nested server error paths must map to visible controls or an understandable form-level summary.

{
  "errors": {
    "billing.address.postal_code": [
      "The postal code does not match the selected country."
    ]
  }
}

Validation is treated as the security control

Input validation is one layer. It does not replace output encoding, parameterized queries, authorization or context-specific security controls.

When Client and Server Rules May Differ Deliberately

Deliberate client/server differences
RuleClient behaviorServer behavior
Required fieldBlock immediatelyEnforce again
Simple formatGive immediate feedbackEnforce again
Current inventoryMay show cached guidanceUse authoritative availability
Unique usernameMay run an availability checkEnforce uniqueness transactionally
Discount eligibilityMay previewMake final decision
Fraud or abuse ruleUsually hiddenEnforce without exposing sensitive logic
AuthorizationAdjust visible controlsEnforce every request
File safetyCheck extension and size for UXInspect content, type, storage and scanning

The goal is not duplicated code for its own sake. The goal is one acceptance contract with appropriate enforcement at every boundary.

What Each Testing Layer Can Prove

Form validation testing layers
Testing layerWhat it can verifyWhat it cannot prove alone
Browser testRequired fields, input events, visible formats, conditional controls, error rendering and recoveryServer enforcement or stored representation
Constraint API inspectionValidityState, native constraints and custom browser validityHandcrafted-request handling
Form API testRequest schema, field rules, cross-field rules and structured error responsesAccessible presentation in the browser
Server integration testAuthoritative semantic rules and downstream validationReal user correction flow
Storage checkNormalized and persisted representationBrowser instructions or accessible errors
Accessibility evaluationLabels, required state, focus, announcements and error discoveryServer data integrity
Security reviewValidation bypass, payload limits, regex risk and interaction with other controlsGeneral usability
Localization testDates, numbers, messages, direction and input methodsComplete server protection
Form validation testing layers covering browser behavior, constraint APIs, server rules, storage, accessibility, localization, and security
A browser check is vital, but it is only one layer in a complete validation contract.

A browser can show "Enter a valid email address." It cannot prove that the server rejects the same request after browser validation has been removed.

How to Select Validation Cases After a Change

Change-to-regression-scope matrix
Changed componentMinimum regression scope
Required or optional statusEmpty, valid, whitespace, group control and server bypass
String lengthmin-1, min, max, max+1, paste and direct API
Numeric rangeBelow, boundary, above, precision, step and locale
Format patternSupported formats, malformed values, Unicode and server parity
NormalizationRaw value, normalized value, equality and storage
Conditional fieldCondition on, condition off, previous value and request inclusion
Cross-field ruleValid combinations, invalid relationship, missing dependency and correction
API error schemaField mapping, form-level mapping, preserved data and retry
Client validation libraryNative input, paste, autofill, mobile and JavaScript bypass
Server validation libraryDirect API, unknown fields, payload limits and downstream storage
Deployment or feature flagOld client/new server and new client/old server combinations
LocalizationDisplay format, parser, browser locale, server locale and stored representation

Do not execute every negative string after every change. Run the cases that cross the changed rule, its boundaries and the layers enforcing it.

Automating Form Validation Test Cases

Many validation scenarios can reuse one browser flow:

Open the form
Fill fields from {{DATASET}}
Submit the form
Assert {{EXPECTED_FIELD_ERRORS}}
Assert {{EXPECTED_FORM_RESULT}}

A positive dataset can describe both inputs and expected results:

{
  "name": "minimum valid name",
  "values": {
    "displayName": "Li",
    "email": "[email protected]",
    "quantity": 10
  },
  "expected": {
    "accepted": true,
    "fieldErrors": {}
  }
}

A negative boundary case can reuse the same flow:

{
  "name": "name below minimum length",
  "values": {
    "displayName": "L",
    "email": "[email protected]",
    "quantity": 10
  },
  "expected": {
    "accepted": false,
    "fieldErrors": {
      "displayName": "Enter at least 2 characters"
    }
  }
}

Separate browser and API assertions

The browser flow should verify visible errors, focus, retained values, correction and successful resubmission. The API or integration layer should verify status codes, structured error bodies, server enforcement, normalization and the absence of invalid stored data.

Keep rule data centralized where practical

A stable validation schema may provide required, minimum, maximum, pattern, allowed values and dependencies. Generated cases still need review because schemas do not automatically describe useful error wording, legitimate Unicode, normalization order, semantic business rules, recovery behavior or accessibility.

What Browser Automation Should Not Claim

Browser automation should not be presented as proof of complete server-side enforcement, protection against SQL injection or XSS, safe database queries, absence of regex denial-of-service risk, secure file inspection, every Unicode normalization edge case, every locale-specific parsing rule, authorization, or safe handling of every oversized payload.

Browser automation remains valuable because it proves that real users can see, understand, correct and resubmit invalid form data.

Frequently Asked Questions

Should validation happen on blur or only on submit?

Use the interaction pattern defined for the product. Test the selected event sequence, correction behavior and accessibility instead of assuming one universal trigger.

Should the UI and API use exactly the same code?

Not necessarily. They need a compatible acceptance contract. Shared schemas can reduce drift but do not replace integration tests.

Should all special characters be rejected?

No. Permitted characters depend on the field. Apostrophes, hyphens, diacritics and non-Latin letters can be legitimate.

Is an invalid email address a security problem?

Usually it is first a data-quality and workflow problem. Email-format validation does not replace unrelated security controls.

Should server errors clear the form?

Usually no. Preserve valid non-sensitive data so the user can correct the problem. Sensitive fields may require a separate retention policy.

Form Validation Testing Checklist

Before approving form validation, confirm that one valid complete dataset is accepted, optional fields can be omitted, required fields reject empty and whitespace-only values, field groups expose one understandable required-state error, minimum and maximum boundaries use the intended inclusivity, numbers enforce type and range, dates use the intended calendar and timezone, every documented format has positive and negative cases, whitespace handling is explicit, supported Unicode is accepted, normalization occurs in a defined order, cross-field relationships use the complete form state, conditional fields update required and validity states, hidden fields do not block unexpectedly, browser constraints can be bypassed without bypassing the server, UI and API reach compatible acceptance decisions, server-only rejections map to useful visible errors, errors remain discoverable, valid non-sensitive data survives unsuccessful submission, successful retry creates one result, and mobile, paste, autofill and localized input are covered.

Final acceptance criterion. The final acceptance criterion is not: "Invalid values displayed a red error message." It is: "The same documented business rule accepted legitimate data and rejected invalid data at every relevant boundary, while preserving the user's valid input and providing a clear path to correction."

Automate the Repeatable Browser Layer

WrightTest lets teams record one reusable form flow, replace fixed values with named datasets, run each validation case independently and inspect screenshots, step results, errors and Playwright traces.

The browser checks can be exported to native Playwright .spec.ts files when they need to move into an existing repository or CI pipeline.

Use WrightTest to prove the visible validation and correction journey. Combine it with API, server, storage, accessibility and security checks to verify the complete validation contract.