Automatically removing text from a username

C

Colin

Hello,

I am creating a form that automatically picks up the person's username and
inputs it into the form. The username's in our organization ire in the
following format:

firstname.lastname

What I want to be able to do is strip out the period in-between the first
and last name, then put the last name first and the first name last with a
comma in-between them.

Can anyone provide me with a quick chunk of JScript code that can easily
take care of this for me?
 
S

S.Y.M. Wong-A-Ton

Haven't tested this, but it should work.

---
var oldName = "firstname.lastname";
var arrNameParts = oldName.split(".");
var newName = "";
if (arrNameParts.length == 2)
{
newName = arrNameParts[1] + ", " + arrNameParts[0];
}
 
C

Colin

it worked great, thank you very much

S.Y.M. Wong-A-Ton said:
Haven't tested this, but it should work.

---
var oldName = "firstname.lastname";
var arrNameParts = oldName.split(".");
var newName = "";
if (arrNameParts.length == 2)
{
newName = arrNameParts[1] + ", " + arrNameParts[0];
}

---
S.Y.M. Wong-A-Ton


Colin said:
Hello,

I am creating a form that automatically picks up the person's username and
inputs it into the form. The username's in our organization ire in the
following format:

firstname.lastname

What I want to be able to do is strip out the period in-between the first
and last name, then put the last name first and the first name last with a
comma in-between them.

Can anyone provide me with a quick chunk of JScript code that can easily
take care of this for me?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top