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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:32:02+00:00 2026-05-26T02:32:02+00:00

i have a textbox which is not bound. <TextBox x:Name=inputBox Grid.Column=1 Grid.Row=1 /> The

  • 0

i have a textbox which is not bound.

<TextBox x:Name="inputBox" Grid.Column="1" Grid.Row="1"  />

The textbox is to only accept numbers (doubles) and show a warning at once something else(letters or symbols) is written in to the box.

On the TextChanged event, i do some calculations depending on the value enterd and show it in a TextBlock, therefor i need some way of validating that the input is a number as the user writes in the box, but i am having a hard time finding a good way to do this.

Any ideas?

  • 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-05-26T02:32:03+00:00Added an answer on May 26, 2026 at 2:32 am

    What I have used before is a regex to disallow non-numeric characters. Maybe this is something that could be adapted?

    My code was for a port on a server so only numbers but should be straightforward to add the . for doubles (I think “[^0-9\.]” should work but regexs aren’t something I am fantastically good at 🙂 )

    // Text change in Port text box
    private void txtPort_TextChanged(object sender, TextChangedEventArgs e)
    {
        // Only allow numeric input into the Port setting.
        Regex rxAllowed = new Regex(@"[^0-9]", RegexOptions.IgnoreCase);
    
        txtPort.Text = rxAllowed.Replace(txtPort.Text, ""); 
        txtPort.SelectionStart = txtPort.Text.Length; 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TextBox bound to a property of an object which implements IDataErrorInfo
I have some C# / asp.net code I inherited which has a textbox which
I have an asp.net TextBox in which I want to check if the text
I have a numeric textbox in C# .NET which is nothing more than a
I have UserControl which contains a TextBox and a Button control. The Button opens
I have a user control which has a textbox on it, now this usercontrol
I have a UserControl which contains a TextBox . When my main window loads
I have a DataListItem which can potentially be a dropdownlist or a textbox. To
I have a asp:GridView which contains a asp:TextBox within a TemplateField. I would like
I have to compare 2 values which are the text property of 2 textbox

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.