Skip to content

checkBaseFormat(id) ​

Validate the basic format of an ID number (length and characters).

Signature ​

typescript
function checkBaseFormat(id: string): boolean

Parameters ​

ParameterTypeDescription
idstringID number

Returns ​

Returns true if the format is correct (15 digits, or 17 digits + an optional trailing X), false otherwise.

Live Demo ​

Example ​

typescript
import { checkBaseFormat } from 'china-id-card'

checkBaseFormat('622922197808118498') // → true
checkBaseFormat('110101900101001')   // → true (15-digit)
checkBaseFormat('12345')             // → false

基于 GB 11643-1999 标准