Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 87599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:25:41+00:00 2026-05-10T22:25:41+00:00

I have a field in my form labeled Name that will contain both the

  • 0

I have a field in my form labeled ‘Name’ that will contain both the First & Last name.

Our existing dynamic server (to which the form is being POSTed to), expects two separate fields (first name, last name).

Can I use Javascript to split the user input into two separate variables before the form is posted to the server? How would I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:25:42+00:00Added an answer on May 10, 2026 at 10:25 pm

    I would process this on the server end to make sure the data that is passed is accurate from what was posted. It’s relatively easy programmatically to split the name, but the problem is how do you define your separator. Most would agree to split it wherever there is a white-space character, but what if they enter a three word name such as Don Juan DiMarco? If you decide to split the name based on whitespace, you’ll have to determine how to assign the first and last names.

    $arrNames = preg_split('/\s+/', $_POST['name']); 

    The above will give you (in PHP) an array of values split by white space. Running that on the string Don Juan DiMarco would give you an array like:

    Array([0] => 'Don', [1] => 'Juan', [2] => 'DiMarco') 

    From there you have to determine which ones are the first name, and which are a middle, and which are a last name. It gets even harder if you have 4 or 5 names entered, which is entirely realistic for certain cultures. All of this is guesswork, which is why I would recommend simply adding a Last Name input field on the front-end. This would eliminate all guess work as to which name is the first name and which is the last name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this field in one form : <input type=text name=promocode id=promoCode value= style=width:24%
I have a field in a CCK node form that is hidden, and has
I have a form field that uses some Javascript to format user input 'price'
I have a form field where a user enters contact information, including name, email,
I have a form field in a view that is separate from my initial
I have a form field that accepts large text from users. It is basically
I have a field that I've labeled 'password', and I'd like the browser to
I have a data entry form where the first field the user wants to
i have a form field <input type=checkbox name=page value=/> and corresponding field in mysql
I have a form field that includes a mixture of HTML and text. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.