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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:36:56+00:00 2026-06-18T10:36:56+00:00

I have a textbox in which the user will enter data in the following

  • 0

I have a textbox in which the user will enter data in the following way.
e.g. 1.2-2012-2
But it could also be; 12.5-2010-4 (Emphasis on the first part)
My first approach was a MaskedTextBox but as the first part does not have a definite size, I can’t use that.
Now I want to validate the textbox. i.e. I will let the user enter what he/she wants to but in the end I want to know if he/she has entered it in the correct way.
e.g. If the user types a12.4/2012^14 (which is incorrect) I would know.
I have no idea how to convert this idea into code so please could someone guide me.
If there’s an alternative approach.

  • 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-18T10:36:57+00:00Added an answer on June 18, 2026 at 10:36 am

    You can use TextChanged event and Regex expression:

    private void textBox1_TextChanged(object sender, EventArgs e)
    {
        var myRegex = new Regex(@"^(\d)+\.\d-(\d){4}-\d$");
    
        if (myRegex.IsMatch(textBox1.Text))
        {
            //Validation is ok
        }
        else
        {
            //Validation isn't ok
        }
    }
    

    I have tested this code. It’s works. The only thing I don’t know your pattern exactly but above one should work.

    If . is optional then use this pattern: @"^(\d)+(\.\d)*-(\d){4}-\d$"

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

Sidebar

Related Questions

I have a textbox, in which user will enter a Landmark and I have
Scenario: I have multiple text boxes in which a user will enter data into
I have a textbox in my application in which user will enter where clause
I am having a Password textbox which will have empty value. when the user
Desktop window application. I have textbox in which user give values in numbers. what
I have a web form where I have a textbox in which the user
I have a WPF TextBox in which I want to allow autocompleting user names
I have a textbox.T he user will be entering entering a number in this
I have many TextBOX in asp.net which accepts the value from user and stores
I have a textbox for username in a form, when user enter the username,

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.