Skip to content

Help center

How to validate phone numbers in a signup form

Validate phone numbers on your server at signup: read the country, store E.164, check line type, and send a one-time code only to numbers that can receive it.

Updated 2026-11-23

Validate on your server when the form is submitted: send the number with a country, store the e164 value, branch on status and line_type, and send a one-time code only to numbers that passed. Validation tells you the number can exist and what type it is. The code proves the person holds it.

The flow

  1. The person picks a country and types a number.
  2. Your server sends both to the phone endpoint.
  3. You accept, ask for a correction, or add a verification step, based on the result.
  4. You store e164, never the raw input.

Free way, while you design the form

Try real inputs from your market in the phone validator and the phone number formatter. See which formats people type and which results come back. Add a country selector next to the field, and a light pattern check in the browser for feedback only.

With the API

bash
curl https://api.qelka.com/v1/phone \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"phone": "06 12 34 56 78", "country": "FR"}'

A basic call costs 1 credit. The fields to read:

json
{
  "valid": true,
  "status": "valid",
  "e164": "+33612345678",
  "line_type": "mobile",
  "country": { "code": "FR", "name": "France", "calling_code": "33" }
}
status line_type At signup
valid mobile Accept, store e164, send the code.
valid landline, toll_free, premium_rate Ask for a mobile number if you need SMS.
valid fixed_line_or_mobile Accept. Run a live lookup if SMS delivery matters.
valid voip Accept and add a code. See Identify VoIP numbers.
invalid any Ask the person to check the number.
unknown unknown Missing country. Ask again.

In Node.js:

javascript
export async function checkPhone(phone, country) {
  const response = await fetch('https://api.qelka.com/v1/phone', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(country ? { phone, country } : { phone }),
    signal: AbortSignal.timeout(5000),
  })
  if (!response.ok) return { outcome: 'accept_unchecked' }
  const result = await response.json()
  if (result.status === 'unknown') return { outcome: 'ask_country' }
  if (!result.valid) return { outcome: 'ask_correction' }
  return { outcome: 'accept', e164: result.e164, lineType: result.line_type }
}

Fail open: if the API errors or times out, accept the number and check it later. A validation service should not be the reason nobody can sign up. See validate signup forms for the version with email and IP checks in one batch.

Choose the country

In order of reliability: the person's selection, a country you already know such as the billing address, then the country of the request. The last is a guess for travelers and VPN users, so let them change it. Avoid a fixed default for everyone.

Common mistakes

  • Calling the API from the browser. It exposes your key.
  • Validating on every keystroke. Each call costs credits. Check on submit.
  • Storing the typed number. Store e164, display with national.
  • Blocking on unknown. It is a missing country, not a bad number.
  • Skipping the code. Valid does not mean owned.

Frequently asked questions

Should I validate the phone number in the browser or on the server?
Both, for different jobs. In the browser, use a light check for instant feedback as the person types. On the server, call the validation API once on submit, because it needs your secret key and the real numbering plan data. Never call the API from the browser: anyone could copy the key and spend your credits.
What should I do when the check returns unknown?
It means the number was written without a plus sign and the request had no country, so it could not be read. Ask for the country, use a country selector next to the field, or fall back to the country you know from the billing address. Then send the request again with the country field.
Do I still need an SMS code if I validate the number?
Yes, if you must be sure the person holds the phone. Validation checks that the number can exist and what type it is. It does not prove ownership. Validate first, so you never pay to send a code to an impossible number, then send the code to numbers that passed and can receive text.

Put this check in your product

Get an API key in under a minute. 100 free credits every month, no card required.

  • 100 free credits a month
  • No card
  • Test keys spend nothing
  • Cancel any time