Created
April 18, 2013 14:53
-
-
Save najlepsiwebdesigner/5413361 to your computer and use it in GitHub Desktop.
Validates slovak ID identifiers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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