Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
Stay in the Know
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
Be sure you're subscribed to NetSuite communication to stay in the know about monthly happenings, updates and announcements. Subscribe
Code Snippet: Formatting a social security number
nothing too crazy, but might be handy if anyone out there needs to do this (as I did).
/** * Formats raw input to ###-##-#### format * @param {String} raw Source string to format * @return {String} The formatted string */ PMDUtils.FormatSsn = function PMDUtils_formatSsn(raw) { Guard.NotNullOrEmpty(raw, 'A valid ssn string is required'); var newString = []; var currCharCode; var delimiter = '-'; // Copy only the numeric characters into a clean buffer for(var i = 0, len = raw.length, j = 0; i < len ; i++) { currCharCode = raw.charCodeAt(i); // Character codes for ints 1 - 9 are 48 - 57 if (j < 9 && currCharCode >= 48 && currCharCode <= 57) { newString.push(raw.charAt(i)); if(j === 2 || j === 4) { newString.push(delimiter); } j++; } } return newString.join(''); }
Steve Klett | Senior Developer
NetValue Technology
0