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 8233611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:11:18+00:00 2026-06-07T18:11:18+00:00

Possible Duplicate: How do I replace multiple spaces with a single space in C#?

  • 0

Possible Duplicate:
How do I replace multiple spaces with a single space in C#?

I have a TextBox in which user is going to enter search Criteria in TEXTBOX. Now, i want to prevent the user from entering NOT MORE THAN ONE SPACE AFTER EACH WORD in TEXTBOX. How to do it in C#.

Thanks in Advance!

  • 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-07T18:11:20+00:00Added an answer on June 7, 2026 at 6:11 pm

    If you are looking to do it via the server side you could do a simple regex that would replace any double spaces with a singular space

    RegexOptions options = RegexOptions.None;
    Regex regex = new Regex(@"[ ]{2,}", options);     
    MyTextBox.Text= regex.Replace(MyTextBox.Text, @" ");
    

    If you wan to do it on the client side you can still use the same regex but do it on JavaScript and fire it on the onBlur event

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

Sidebar

Related Questions

Possible Duplicate: How do I replace multiple spaces with a single space in C#?
Possible Duplicate: Remove all multiple spaces in Javascript and replace with single space How
Possible Duplicate: Replace multiple whitespaces with single whitespace in JavaScript string I have used
Possible Duplicate: Search and replace inside an associative array I think this may have
Possible Duplicate: JavaScript replace all / with \ in a string? I have a
Possible Duplicate: How to replace string in SQLite? I have a table column data
Possible Duplicate: Can I protect against SQL Injection by escaping single-quote and surrounding user
Possible Duplicate: replace multiple placeholders with php? I've got a .txt-file working as a
Possible Duplicate: Replace only first match using preg_replace I have a string as follows:
Possible Duplicate: Replace all occurrences of substring in a string - which is more

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.