Swedish personal identity numbers validation

How to validate Swedish personal identity number in yii and javascript?

Format :


I don’t see how this question is connected with Yii framework? There are other websites and web communities where you can ask about algorithms, sql, javascript or generally about your code (for example StackOverflow).

P.S. - You can find answer here: https://ipsec.pl/data-protection/2012/european-personal-data-regexp-patterns.html