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

  • SEARCH
  • Home
  • 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 7923145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:12:39+00:00 2026-06-03T17:12:39+00:00

I have a field that a user can input first and last name to

  • 0

I have a field that a user can input first and last name to fill out my form. Sometimes, users put on their first name and that results in empty fields in my database. PLEASE keep in mind that I cannot change this method completely because this form is part of a bigger project and it is being used by other websites of my company.

This is the part of the code that i need the validation around it. I already have a validation that ensures that the filed is not empty but I need on more to ensure that the field has two items in it separated by space.

<input name="fullname" class="fullname"   type="text" value="#fullname#" maxlength="150"/>
            <cfif fullname eq '' and check2 eq 'check2'>
            <br /><span style="color:red">*you must enter your full name</span></cfif>

The check2 eq ‘check2’ is checking if the form was submitted already to ensure a user submitting their data twice.

I thought of using regular expressions to do that but unfortunately I am not very familiar with how to use regx in CF9 and the documentation online through me off a bit.

I was also thinking to use “Find” or “FindOneOF”, any thoughts on that?

Also, I am trying to avoid using JQ,JS etc, so please try to keep your suggestions based on CF code IF possible.

Any help or different suggestions on how to tackle this issue will be very appreciated.

  • 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. Editorial Team
    Editorial Team
    2026-06-03T17:12:44+00:00Added an answer on June 3, 2026 at 5:12 pm

    You could do something like this for server side validation:

    <cfscript>
    TheString = "ronger ddd";
    TheString = trim(TheString); // get rid of beginning and ending spaces
    SpaceAt = reFind(" ", TheString); // find the index of a space
    
    // no space found -- one word
    if (SpaceAt == 0) {
        FullNameHasSpace = false;
    // at least one space was found -- more than one word
    } else {
        FullNameHasSpace = true;
    }
    </cfscript>
    
    <cfoutput>
    <input type="input" value="#TheString#">
    <cfif FullNameHasSpace eq true>
        <p>found space at position #SpaceAt#</p>    
        <p>Your data is good.</p>
    <cfelse>
        <p>Did not find a space.</p>
        <p>Your data is bad.</p>
    </cfif>
    </cfoutput>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a text field that a user can enter a
I have a text field that can accept input of any kind. Based on
I have a page which displays a form that a logged-in user can use
within a form I have a section that allows the user to build out
I have a field in my form labeled Name that will contain both the
Stuck with a silly problem. I have an input field, where user can input
I have an activity that contains several user editable items (an EditText field, RatingBar,
I have a user table 'users' that has fields like: id first_name last_name ...
Supposing that I have millions of user profiles, with hundreds of fields (name, gender,
I have strange behavior in FuelPHP. I generate form field with FuelPHP Form::input() method.

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.