javascript format social security number

Solutions on MaxInterview for javascript format social security number by the best coders in the world

showing results for - "javascript format social security number"
Charlotte
24 Nov 2016
1function formatSocialSecurity(val){
2	val = val.replace(/\D/g, '');
3	val = val.replace(/^(\d{3})/, '$1-');
4	val = val.replace(/-(\d{2})/, '-$1-');
5	val = val.replace(/(\d)-(\d{4}).*/, '$1-$2');
6	return val;
7}  		
8formatSocialSecurity("135711458");//"135-71-1458"	
similar questions
queries leading to this page
javascript format social security number