|
-
Feb 7th, 2016, 08:20 PM
#1
Thread Starter
Fanatic Member
Create Unique Field
I've created a 'username' field that will be auto-completed based on first and last name in my form text fields, so it starts as Me.firstname + Me.lastname
What I'd like to do, is verify that no one else has that username first. If they do, I want to loop through their first name, adding a character to the username until it's unique.
For example, lets say I enter:
John Smith... his username would be jsmith - check the database - no values so he gets jsmith
now I go to enter Jane Smith, but when the 'unique' check happens, she can't be jsmith, because there already is one... so it appends the second character to her name, she would be: jasmith.
if I entered June Smith, she would be jusmith, because jsmith is taken, but jusmith is not.
Now, if I wanted to enter Janice Smith, she would end up being jansmith, because jsmith is taken, it tries jasmith, thats taken, so it moves to jansmith.
Does this make sense?
How would I make this type of "recursive" check?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|