Format National Insurance Number


  • Hi All;

    Below is my code to format National Insurance number in CRM

    but it gives the error as follows

    Any help on this is much appreciated


    function testNINO(myNINO) {
        if (checkNINO(myNINO))
            return checkNINO(myNINO);debugger;
          alert("Error:! The NI Number must follow the following format: AA ## ## ## A    For example, NE 53 94 02 D");
          alert("Error: The NI Number must have the following letter/number combinations:\n\n[A-Z] = e.g. SG\n[0-9] = e.g. 56\n[0-9] = e.g. 01\n[0-9] = e.g. 16\n[A-D] = e.g. B"); 
    function checkNINO (toCheck) {
        //var exp1 = /^([A-CEGHJ-NOPR-TW-Z]{1}[A-CEGHJ-NPR-TW-Z]{1})([0-9]{2})([0-9]{2})([0-9]{2})([A-Z\s]{1})/i;
    	var exp1 = /^([A-Z]{1}[A-Z]{1})([0-9]{2})([0-9]{2})([0-9]{2})([A-Z\s]{1})/i;
        var exp2 = /(^GB)|(^BG)|(^NK)|(^KN)|(^TN)|(^NT)|(^ZZ).+/i;
    //if( !sTmp.match( exp2) )
        if (toCheck.match(exp1) && !toCheck.match(exp2)) {
            var strFormated = toCheck.replace(exp1, "$1 $2 $3 $4 $5");
            return strFormated.toUpperCase();
        else {
            return false;


    Wednesday, February 19, 2014 3:46 PM

All replies

  • Silly question, but have you added this JavaScript web resource to that specific form?
    Wednesday, February 19, 2014 4:23 PM
  • I just put this into a Lint and it returned several errors. You may try fixing the ones it has found. If you have any errors like these it will return the error you are getting saying the function is undefined. I posted the website I use below.

    Wednesday, February 19, 2014 4:43 PM
  • yes i did


    Wednesday, February 19, 2014 11:14 PM