Choose a card type
How many?
1

Test data only. Local fixtures do not issue cards, verify accounts or provide payment authorization. Use them only in authorized tests. Why?

VisaTEST CARD
•••• •••• •••• ••••
Cardholder—
ExpiresMM/YY
CVV•••
  • Generated fields are not uploaded
  • Randomly generated in your browser
  • Every number passes the Luhn check

Test JCB before the user finishes typing

Checking a full JCB fixture misses an input-state problem: the form may display an error at 35, leave that error visible after a correction, or stop accepting digits as soon as the number reaches sixteen characters. This exercise follows the input through those states instead of testing only the final value.

The generator above emits 16-digit, Luhn-valid numbers from the 3528–3589 prefix range, with a three-digit synthetic security code. The separate JSON fixture extends the length cases for a form configured to accept 16 through 19 digits.

Separate possible, complete and verified

Cybersource’s JCB identification reference lists 3528–3589 and 16–19 digits. That is the explicit profile for the sample below; it is not an exhaustive issuer database. Braintree’s card-validator documentation likewise distinguishes potentially valid input from a completed validation result.

Here, candidate means the typed prefix has reached four digits inside the configured range. complete-shape means the prefix and length fit. Neither label means a checksum was verified. One fixture deliberately has a wrong check digit while retaining the same shape, so the distinction is visible in the tests.

Input or actionExpected stateUI behavior to check
Empty inputemptyClear stale brand and error state
3, 35, then 352incomplete, candidate falseAllow more typing without claiming a completed JCB match
3528 or 3589incomplete, candidate trueA provisional brand may appear; number remains unfinished
3527 or 3590outside-profileExplain that this prefix does not match the configured profile
Backspace from 3590 to 35incomplete againRemove the previous prefix error
Reach 16, 17 or 18 digitscomplete-shape, can continueDo not auto-submit or truncate the next digit
Reach 19, then 20 digitsComplete shape, then too-longRetain the entered value and show the length error

The card-length guide is a reference for choosing your application’s profile. Do not infer support from one fixture or enable every length without checking the processor integration you use.

Run the typing-state model

Download the JCB typing cases and the runnable input-state example together:

node --test jcb-typing.test.mjs

The runner checks the fixture states, every shorter prefix of the 19-digit example, and recovery after backspacing an out-of-profile prefix. This is the same model displayed here:

function jcbInputState(value) {
  if (typeof value !== 'string') throw new TypeError('Use a string');
  if (value === '') return { state: 'empty', candidate: false, canContinue: true };
  if (!/^[0-9]+$/.test(value)) {
    return { state: 'characters', candidate: false, canContinue: false };
  }
  const prefix = value.slice(0, 4);
  const low = Number(prefix.padEnd(4, '0'));
  const high = Number(prefix.padEnd(4, '9'));
  if (high < 3528 || low > 3589) {
    return { state: 'outside-profile', candidate: false, canContinue: false };
  }
  const candidate = value.length >= 4;
  const state = value.length > 19 ? 'too-long'
    : value.length >= 16 ? 'complete-shape' : 'incomplete';
  return { state, candidate, canContinue: value.length < 19 };
}

The function accepts an unformatted digit string. Spaces and letters return characters; they are not silently removed. If your input component supports pasted separators, test that normalization separately with the Visa input fixtures, then feed its output into the state model. Keep the number as a string throughout.

Replay the sequence in your form

Replace jcbInputState in a copy of the runner with an adapter that returns the equivalent states from your own component. Then type the sequence in a development checkout, including backspace and replacement, without reloading the page between steps.

Observe whether the field error clears, whether focus stays in the input, and whether a sixteen-character mask prevents the seventeenth digit from reaching validation at all. A passing model test cannot detect that DOM-level truncation. For caret placement while editing a formatted number, use the Diners input-mask exercise.

Keep brand detection, checksum feedback and submission readiness as separate assertions. This sample never enables a payment button: a complete shape is just one input to that decision. Gateway behavior belongs in a second suite using your provider’s published fixtures from the sandbox reference.

Frequently Asked Questions

Should the form reject JCB when only 35 has been typed?
No. In this example, 35 is an incomplete prefix that can still become a match. It is not enough to select a confirmed brand or to consider the number complete.
What does complete-shape mean in the download?
The digit string matches the configured 3528–3589 prefix and a length from 16 to 19. This state does not check Luhn, security codes, merchant acceptance or payment authorization.
Does the generator produce the longer fixture lengths?
No. The generator produces 16 digits. The downloadable typing fixture separately includes 17-, 18- and 19-digit strings so you can test a form configured for those lengths.
Why can a complete 16-digit shape still accept another digit?
The sample profile also supports longer shapes. Completion at one allowed length should not force an automatic submission or prevent the user from continuing to 19 digits.