I have a title like Virtual Team Resources then i need its short code like VTR
If Title Virtual Team then ShortCOde will be VTE
i have implement this but still some issues like
if user enter title Virtual T then short code will ?
My Code——
function EnterShortCode() {
debugger
var ProjectShortCode = "";
var Arr = $("#txtProjectTitle").val().rtrim().split(" ");
for (i = 0; i < Arr.length; i++) {
if (Arr[i] != "" && Arr[i] != null) {
ProjectShortCode += Arr[i].substring(0, 1);
if (i == Arr.length - 1) {
if (ProjectShortCode.length == 1) {
if (Arr[i] < 3) {
}
else {
ProjectShortCode = ProjectShortCode + Arr[i].substring(1, 3);
}
}
else if (ProjectShortCode.length == 2) {
if (Arr[i] < 2) {
}
else {
ProjectShortCode = ProjectShortCode + Arr[i].substring(1, 2)
}
}
}
}
}
ProjectShortCode = ProjectShortCode.toUpperCase();
alert(ProjectShortCode);
}
i have modified your function slightly that may help you
LIVE DEMO