Standardize Format of a Text Input and Save as Embedded Data (JS?) | XM Community
Skip to main content

Hi Community!
I have a text entry question wherein I ask participants "What is your first name?"
I want to take their answer and store it as an embedded data field.
If someone inputs their first name (e.g., "Ayanna" or "Will"), things work perfectly! I use Survey Flow to set embedded data from their input.
The problem is that some people are inputting their names badly:

  • Not capitalizing the first initial: "joe"

  • Capitalizing every letter: "JOE"

  • Including a last initial: "Joe T" or "Joe T."

  • Including a last initial as one word: "JoeT"

  • Weird typos: ", Joe"

I think this will somehow require JavaScript, but I'm not sure (a) how to do this (I think it involves something called "regular expressions"?), or even (b) where I would implement this (survey flow? question javascript?).
Question: How do I take people's text input and standardize the format--capitalized first letter, just 1 word, nothing extraneous--and save it as an embedded data?
*I'm so grateful for any guidance you might have!*

Anyone have any clues?


Leave a Reply