Skip to main content
Participating Frequently
April 7, 2022
Answered

Formatting name text to Last name uppercase and first name lower case

  • April 7, 2022
  • 1 reply
  • 1378 views

I have a form that has a single name field: "LAST NAME, First name" in the same field. I copy and paste the name in from other source but it comes in all different formatting, sometimes all lower case sometimes in all upper case. Is it possible to have a script that changes the formatting to last name all upper case e.g (SMITH) and first name normal e.g (John) with the comma in between as above? e.g  Name:  SMITH, John.

I have been looking for the right script to use for this for so long.   

This topic has been closed for replies.
Correct answer try67

Try this code:

 

if (event.value) {
	var parts = event.value.split(", ");
	if (parts.length==2) {
		event.value = parts[0].toUpperCase() + ", " + parts[1].charAt(0).toUpperCase() + parts[1].substr(1).toLowerCase();
	}
}

1 reply

try67
Community Expert
Community Expert
April 7, 2022

Are you talking about changing the name of the field, or changing its value?

If the latter, are you talking about changing the actual value, or just how it is presented on the page (its formatting)?

Participating Frequently
April 7, 2022

Changing the value.  I copy the persons name from a different form into my form.  I need the field to auto format to upper case last name and lower case first name (with capital at the start of course).   It can be just the way it's presented that changes as long as it stays that way when it's printed.

Participating Frequently
April 7, 2022

Sorry, I mean i need the value to auto fomat