Skip to content

Instantly share code, notes, and snippets.

@najlepsiwebdesigner
Created April 18, 2013 14:53
Show Gist options
  • Save najlepsiwebdesigner/5413361 to your computer and use it in GitHub Desktop.
Save najlepsiwebdesigner/5413361 to your computer and use it in GitHub Desktop.
Validates slovak ID identifiers
/*
* validates slovak ID numbers
*
* @param string skIdNumber slovak ID number
*
* @return bool
*/
function validateSkId (skIdNumber) {
if (skIdNumber == undefined ||
skIdNumber.length < 1 ||
skIdNumber == null){
return false;
}
// remove all spaces from string
skIdNumber = skIdNumber.replace(/\s+/g, '');
//check length after space removal
if (skIdNumber.length != 8){
return false;
}
// AA XXXXXX - two characters + 6 numbers
var re = /([a-zA-Z]){2}([0-9]){6}/;
return re.test(skIdNumber);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment