Search String for Multiple Words


#1

Hi there,

I am working on some form validation and seem to be stuck. I have a field called “Full Name.” This field is designed to collect a first, middle, and last name from a user. My goal is to guide the user through the field. For example, when the user focuses on the field they are first prompted “we need your first name” after they enter their first name the user is prompted “we need your middle name” on text change. Finally after a user types their middle name they are prompted to enter their last name. Once the user types their last name the user has prompted that field is complete.

I have tried index of, and length but it is not working. Does anyone know how to solve this?


#2

Before doing anything in Axure: how are you defining a “name”? Some characters followed by a space? How do you plan to determine when a first name has been entered?


#3

Why not have three separate fields, first, middle and lastname and after the three are filled combine them in an automated filled field? This will probably work better as people might have all kind of weird names (I know because my lastname consist of 4 parts which often won’t fit in fields or all get capitalized)


#4

@adammroot,

Here is a “start”… Not perfect, lots of ways it breaks, but it does what you ask.
Progressive Name Field.rp (64.4 KB)

Per nkrisc’s good question, I assumed that a space char or enter key would separate the parts of the full name. I put your various instructions into a dynamic panel and set its state to track what name parts have been entered (First, Middle, Last) and use the OnKeyUp event of the text field to process the input, setting the “Name Field Prompt” panel to the next state. When all have been entered, a confirmation checkmark shape is shown.

Now, this approach avoids the need to “search string for multiple words” and for good reason–this isn’t easy in Axure. Better done in pure javascript with regular expressions (just search Stack Overflow site with your question to find solutions) --and actually that javascript can be called from Axure with javascript injection (search this forum for that term to learn more.)


#5

This is also a candidate for the “it’s just a prototype” discussion. Depending on what you are going to do with your prototype, it might not be worth the effort to fully make this work in the prototype. I commend the user experience idea of allowing the user to type their own name naturally—not forcing them to tab into different fields etc.—but share @nkrisc and @Herman 's concerns about how you define a name, both technically (spaces? what about hyphens) and the cultural assumption that there are three names (some cultures have more, some have less, a problem which is not solved by having separate boxes, of course).


#6

You hit the nail on the head and why I was asking. Trying to codify what a “name” is when accounting for all cultural varieties of a name is basically an unsolvable problem (in terms of completely solving).

If you must know the individual parts of a user’s name (still loaded with assumptions), use separate fields. Don’t try to parse a string into different name values.

For example, what if I don’t have a middle name? Based on the limited requirements given here that would totally break your system. And having no middle name is pretty common of all the different name-related edge cases.

Here’s another fun one: What if I share a name with the famous architect Ludwig Mies van der Rohe? Good luck with that. Your current method won’t work on that.

Sure it’s just a prototype, but can what you’re prototyping even be built?


#7

To be fair, we could adapt @adammroot 's original idea into something quite interesting. Imaging parsing the user’s (single-field) entry into separate parts (“Fred” “van” “der” “Rohe”) and then ask “which of these is your family name?” “which is your given name?” “which of these do you prefer to be called by?” etc.
But of course the original question was how to separate one string into many … which is maybe doable using substr() or substring() or “onkeyup where key = (space)” … and to react to the separator with a prompt (“what’s the next part of your name?”), not to go into all the details of cultural naming conventions. He’s (I assume “he” based on ‘adam’, I stipulate I could be wrong!) probably doing a facepalm and wondering, what did I do to deserve this?
Meant in a spirit of collegial regard,
Jacque


#8

Hey btw, what @mbc66 put together is a fair start … because really, the “What is your first name” etc is really just a culturally-specific way of asking about the parts of a name … noticing that he (now I’m assuming from the avatar! Looks like a ‘he.’) has given the user the opportunity to skip a part if it doesn’t apply. That could be extended…
I’ll stop now! :blush:
Jacque


#9

First name space middle name space last name


#10

Won’t work for me,
First name: “Herman”
Middle name: “”
Last name: “Eberstadt van der Velden”.
As you see 3 spaces in last name.