You are here: irt.org | FAQ | JavaScript | Text | Q1658 [ previous next ]
Try:
<script language="JavaScript"><!-- function insertNthChar(string,chr,nth) { var output = ''; for (var i=0; i<string.length; i++) { if (i>0 && i%4 == 0) output += chr; output += string.charAt(i); } return output; } alert(insertNthChar('erty1f213dfs1111', '-', 4)); //--></script>