var cleanstring = x1.replace(/\,/g,'');
no=cleanstring.length;
switch(no)
{
case 3: str=cleanstring.substr(0);
document.getElementById(ids).value=str;
break;
case 4: str=cleanstring.substr(1);
str1=cleanstring.substr(0,1);
document.getElementById(ids).value=str1+","+str;
break;
case 5:
str=cleanstring.substr(2);
str1=cleanstring.substr(0,2);
document.getElementById(ids).value=str1+","+str;
break;
case 6:
str=cleanstring.substr(3);
str1=cleanstring.substr(1,2);
str2=cleanstring.substr(0,1);
document.getElementById(ids).value=str2+","+str1+","+str;
break;
case 7:
str=cleanstring.substr(4);
str1=cleanstring.substr(2,2);
str2=cleanstring.substr(0,2);
document.getElementById(ids).value=str2+","+str1+","+str;
break;
case 8:
str=cleanstring.substr(5);
str1=cleanstring.substr(3,2);
str2=cleanstring.substr(1,2);
str3=cleanstring.substr(0,1);
document.getElementById(ids).value=str3+","+str2+","+str1+","+str;
break;
case 9:
str=cleanstring.substr(6);
str1=cleanstring.substr(4,2);
str2=cleanstring.substr(2,2);
str3=cleanstring.substr(0,2);
document.getElementById(ids).value=str3+","+str2+","+str1+","+str;
break;
case 10:
str=cleanstring.substr(7);
str1=cleanstring.substr(5,2);
str2=cleanstring.substr(3,2);
str3=cleanstring.substr(1,2);
str4=cleanstring.substr(0,1);
document.getElementById(ids).value=str4+","+str3+","+str2+","+str1+","+str;
break;
case 11:
str=cleanstring.substr(8);
str1=cleanstring.substr(6,2);
str2=cleanstring.substr(4,2);
str3=cleanstring.substr(2,2);
str4=cleanstring.substr(0,2);
document.getElementById(ids).value=str4+","+str3+","+str2+","+str1+","+str;
break;
case 12:
str=cleanstring.substr(9); //1,11,11,11,11,111
str1=cleanstring.substr(7,2);
str2=cleanstring.substr(5,2);
str3=cleanstring.substr(3,2);
str4=cleanstring.substr(1,2);
str5=cleanstring.substr(0,1);
document.getElementById(ids).value=str5+","+str4+","+str3+","+str2+","+str1+","+str;
break;
}
}
-->