checkBaseFormat(id)
Validate the basic format of an ID number (length and characters).
Signature
typescript
function checkBaseFormat(id: string): booleanParameters
| Parameter | Type | Description |
|---|---|---|
| id | string | ID 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