Skip navigation |

National Insurance Number

To add a field that collects someone's National Insurance Number to your form, follow these steps to ensure that the user can only enter a valid NI Number.

Last updated: 09 May 2012, 15:55

The official National Insurance Number Specification states that a valid National Insurance Number conforms to seven rules:

  1. Must be 9 characters.
  2. First 2 characters must be alpha.
  3. Next 6 characters must be numeric.
  4. Final character can be A, B, C, D or space.
  5. First character must not be D,F,I,Q,U or V
  6. Second characters must not be D, F, I, O, Q, U or V.
  7. First 2 characters must not be combinations of GB, NK, TN or ZZ (the term combinations covers both GB and BG etc.)

If you want users of your site to supply their NI number, you can ensure that they can only enter a valid one by doing the following.

Add a Single Line Text item and add the following, exactly as shown, to the Parameters box:

^[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z][0-9]{6}[ABCD ]?$

If you want your users to have the option to enter spaces in between the sections of the number, add the following text to the Parameters box:

^[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z] ?([0-9]{2} ?){3} ?[ABCD ]?$

If you want to force your users to put spaces between the sections of the number, add the following text to the Parameters box:

^[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z] ([0-9]{2} ){3} [ABCD ]?$

Note that these do not validate for rule 7.

If you just want to verify that the user has entered 2 letters, 6 numbers and a single letter, use:

^[A-Z]{2}[0-9]{6}[A-Z]$

With optional spaces:

^[A-Z]{2} ?([0-9]{2} ?){3} ?[A-Z]$

With mandatory spaces:

^[A-Z]{2} ([0-9]{2} ){3} [A-Z]$

If you just want to verify that the user has entered 2 letters, 6 numbers and an optional single letter, use:

^[A-Z]{2}[0-9]{6}[A-Z]?$

With optional spaces:

^[A-Z]{2} ?([0-9]{2} ?){3} ?[A-Z]?$

With mandatory spaces:

^[A-Z]{2} ([0-9]{2} ){3} [A-Z]?$

Case insensitive entry

Valid National Insurance numbers must be in uppercase. You can adjust the three parameter strings above to allow your users to enter NI numbers in lower case, if you wish to relax that rule. You can do this by using one of the parameters shown here:

  • ^[A-CEGHJ-PR-TW-Za-ceghj-pr-tw-z][A-CEGHJ-NPR-TW-Za-ceghj-npr-tw-z][0-9]{6}[ABCDabcd ]?$
  • ^[A-Za-z]{2}[0-9]{6}[A-Za-z]$
  • ^[A-Za-z]{2}[0-9]{6}[A-Za-z]?$

With Optional Spaces:

  • ^[A-CEGHJ-PR-TW-Za-ceghj-pr-tw-z][A-CEGHJ-NPR-TW-Za-ceghj-npr-tw-z] ?([0-9]{2} ?){3} ?[ABCDabcd ]?$
  • ^[A-Za-z]{2} ?([0-9]{2} ?){3} ?[A-Za-z]$
  • ^[A-Za-z]{2} ?([0-9]{2} ?){3} ?[A-Za-z]?$

With Mandatory Spaces:

  • ^[A-CEGHJ-PR-TW-Za-ceghj-pr-tw-z][A-CEGHJ-NPR-TW-Za-ceghj-npr-tw-z] ([0-9]{2} ){3} [ABCDabcd ]?$
  • ^[A-Za-z]{2} ([0-9]{2} ){3} [A-Za-z]$
  • ^[A-Za-z]{2} ([0-9]{2} ){3} [A-Za-z]?$
 

Cookies are used by nearly every website to improve your web browsing experience. Recent government legislation (the e-Privacy Directive) means that we are obliged to seek your agreement to the use of cookies when you visit our website. Two of the cookies that we use are essential for this website to operate and have already been set. You may delete and block all cookies from this site, but if you do so, parts of the site will not work. To find out more about the cookies that we use, please see our privacy policy.