ClearPass Guest DoB Regex

I don’t like the ClearPass date/time picker because it picks a time whether you want to or not, which is confusing, and if you’re as old as I am having to click back to find the correct year is tiresome.

Here’s a handy regex validator for UK format date of birth. This is an amalgamation and tweak of several expressions I found when setting up a captive portal for a client.

This format assumes day month year, as commonly used in the UK. It will validate against double or four digit years and allow either dd/mm/yy or dd-mm-yy.

The aim was to be as flexible as possible in the format used.

Clearly it will also validate if someone puts in a date of 4th September 1984 as 09/04/84 so we’re not being super precise about things but this is was deemed good enough and it’s less likely a UK user would use the wrong format.

Although the expression is less prescriptive than this, a validation error was written for clarity so the user it given an example that will validate.

/^(3[01]|[12][0-9]|0?[1-9])(\/|-)(1[0-2]|0?[1-9])\2([0-9]{2})?[0-9]{2}$/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.