• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

No Spaces in text form.

Guest
Apr 25, 2006 Apr 25, 2006

Copy link to clipboard

Copied

Hi, I have a form and in the form I have a text box where the user can input his or her username. However, I dont want to allow them to be able to submit an username with spaces.
For example if the following were usernames:
GoodUsername - is what i want.
Bad User Name -what i dont want and want to prevent users from submitting these kinds of usernames.

please any kind of help will be appreciated. thanks.
TOPICS
Advanced techniques

Views

656

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 25, 2006 Apr 25, 2006

Copy link to clipboard

Copied

When the form is submitted, you can check the string for spaces and display an error message if found. Or you can just remove all spaces in the string. The string functions Find and Replace would do this for you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 25, 2006 Apr 25, 2006

Copy link to clipboard

Copied

To elaborate on dempster's reply, it is a lot easier to program computers than it is to program people. The most user freindly option is to accept what they give you and get rid of the spaces yourself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 09, 2006 May 09, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: Dan Bracuk
the most user freindly option is to accept what they give you and get rid of the spaces yourself.


I would have to disagree on this.

Give them an error message about not allowing spaces.

Otherwise, if you strip out the spaces, they will be calling and emailing you that they cannot log into your site. That is because you changed thier login. Our site use to be the same way. We stripped out the spaces. I finally had it changed. To many "stupid users". Even though we had in large bold red text that 'spaces were not allowed', users cannot read.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
May 09, 2006 May 09, 2006

Copy link to clipboard

Copied

quote:

To many "stupid users"..... users cannot read.


Amen brother! The more that you do to idiot proof your site, the better that you will sleep at night. If you assume that "nobody would ever enter data like that" you will get eventually get burned. People will do some of the stupidest and oddball things, so you have to protect the application.

Press any key.....I can't find the "any" key!

Phil

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 09, 2006 May 09, 2006

Copy link to clipboard

Copied

Why don't we all embrace the sterotype of arrogant tech guys who have to put up with stupid users?

The fact is, on web pages people skim and read quickly and we often need to adjust our approach to conform to user behavior. Yes, it's frustrating when people don't read instructions. But it's frustrating for users when web forms scold them, force them to enter data in strange formats, require fields that have nothing to do with the transaction, etc. etc.

In this case, if there is a legitimate reason for excluding spaces from a username, you can explain that on the form. And when someone puts a space in anyway, why not just correct and notify them that it was corrected? Does it enhance the user experience to flash a big "ERROR! STUPID USER!" message at them?

It's like requiring users to enter a field in uppercase. If the user doesn't type the field in uppercase, do we yell at them? Or just convert it to uppercase?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 09, 2006 May 09, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: asounds
quote:

Originally posted by: Dan Bracuk
the most user freindly option is to accept what they give you and get rid of the spaces yourself.

I would have to disagree on this.
Give them an error message about not allowing spaces.
Otherwise, if you strip out the spaces, they will be calling and emailing you that they cannot log into your site. That is because you changed thier login. Our site use to be the same way. We stripped out the spaces. I finally had it changed. To many "stupid users". Even though we had in large bold red text that 'spaces were not allowed', users cannot read.


Why didn't you strip out the spaces on their subsequent login attempts?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 10, 2006 May 10, 2006

Copy link to clipboard

Copied

Since no one has answered the question. Can you supply more info?
Are you using an HTML or Flash form?
Do you want to do this in JavaScript before the form is entered?
Or after the form is submitted and handle on the server-side?

Also look into CFFORM and CFINPUT with field validation. Check the docs.
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=part_cfm...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 10, 2006 May 10, 2006

Copy link to clipboard

Copied



<script>
str = str.replace(/^\s*|\s*$/g,"")
</script>

I think this will remove all the space from the string .

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 10, 2006 May 10, 2006

Copy link to clipboard

Copied

LATEST
If you want to explore flash forms you can set up a mask to disallow spaces I believe.

Lots of opinions here, mine would be to not alter a user's submission on their behalf (for reasons asounds mentions and others). I prefer to use javascript, wddx, now ActionScript and Flash Remoting to verify what they've done before submission, and place as friendly of an error as possible on the screen before allowing submission. My preference is to have the user understand why they must submit something a particular way if it's important for the site. For a username for example, I don't think rm'ing spaces on their behalf is the best move. If I used a site and tried a username that didn't fit their format, I would personally want a 2nd chance at making a compliant one rather than the system making it compliant and dictating to me what it will be.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation