textbox validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • annaduraidte
    New Member
    • Sep 2008
    • 3

    textbox validation

    i am new to c# progrmming, i am developing a software, in which the text box should accept only numeric , not alpha and blanks,

    could anyone help me in this, thanks

    regds
    annadurai
  • cloud255
    Recognized Expert Contributor
    • Jun 2008
    • 427

    #2
    Hi there, i suggest you look into regular expressions and this thread

    If you still experience problems, please post the relevant code.

    Good luck

    Comment

    • wassssup
      New Member
      • Oct 2007
      • 47

      #3
      as for the numers only, u can use masked text box instead of text box. then in the properties column, under the mask section, put ####. if u only allow lets say 5 digits then put #####
      if u don want it blank, u can put something like this in your code
      string.IsNullOr Empty(masktextb ox.Text)

      Comment

      • annaduraidte
        New Member
        • Sep 2008
        • 3

        #4
        Originally posted by wassssup
        as for the numers only, u can use masked text box instead of text box. then in the properties column, under the mask section, put ####. if u only allow lets say 5 digits then put #####
        if u don want it blank, u can put something like this in your code
        string.IsNullOr Empty(masktextb ox.Text)

        thanks for your reply,
        but i donot find the masked textbox in my tool box

        thanks and regds
        annadurai

        Comment

        • Curtis Rutland
          Recognized Expert Specialist
          • Apr 2008
          • 3264

          #5
          Masked textbox is only available for Windows Forms. I'm guessing that this is ASP.NET?

          When asking questions, you should always include 3 things:
          1. Language
          2. Platform
          3. Framework Version


          Now, the Masked textbox has been made available for use in web apps through the ASP.NET AJAX toolkit, so if you are using Framework 3.5, you might want to look into that.

          Otherwise, you can validate after the postback. Just try to Parse a number, and if it fails, then you know you have invalid data.

          Furthermore, you could write Javascript to validate on the client side. We have a javascript forum that could help you with that. But please do your own research first, as nobody is just going to hand you code.

          Comment

          Working...