Archive for the ‘Validation’ Category

Using Javascript to validate South African ID Numbers

I have just finished a neat little client side ID number validation script that ensures that the ID number passed is:

Numeric,
is 13 Digits long,
has a valid date with the first 6 characters
and passes the Luhn algorithm test.

function ValidateIDnumber(idnumber) {
//1. numeric and 13 digits
if (isNaN(idnumber) || (idnumber.length != 13)) { return false; }
//2. first 6 numbers [...]

More »