Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Make text box to aceept numeric values only?

How to Make text box to aceept numeric values only?

Scheduled Pinned Locked Moved C#
csharptutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    praveenqwe
    wrote on last edited by
    #1

    Hi, Iam new to c# Can, how to make a normal textbox to accept only numeric values and also some specific format.(not using masked textbox). Thank you, regards Praveen

    D M 2 Replies Last reply
    0
    • P praveenqwe

      Hi, Iam new to c# Can, how to make a normal textbox to accept only numeric values and also some specific format.(not using masked textbox). Thank you, regards Praveen

      D Offline
      D Offline
      DIMPLE_R
      wrote on last edited by
      #2

      Use client-side code to validate the data entered..a javascript function will work fine... Refer to: http://www.shiningstar.net/articles/articles/javascript/checkNumeric.asp?ID=AW

      Z 1 Reply Last reply
      0
      • D DIMPLE_R

        Use client-side code to validate the data entered..a javascript function will work fine... Refer to: http://www.shiningstar.net/articles/articles/javascript/checkNumeric.asp?ID=AW

        Z Offline
        Z Offline
        zenithmaximus
        wrote on last edited by
        #3

        An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll -::maximus::-

        Z 1 Reply Last reply
        0
        • Z zenithmaximus

          An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll -::maximus::-

          Z Offline
          Z Offline
          zenithmaximus
          wrote on last edited by
          #4

          ooopppss!! sorry please disregard this message. -::maximus::-

          1 Reply Last reply
          0
          • P praveenqwe

            Hi, Iam new to c# Can, how to make a normal textbox to accept only numeric values and also some specific format.(not using masked textbox). Thank you, regards Praveen

            M Offline
            M Offline
            Martin 0
            wrote on last edited by
            #5

            Hello Praveen, You can create your inherted TextBox and use this code: protected override void OnKeyPress(KeyPressEventArgs e) { string _allowedkeychars = "1234567890"; if (_allowedkeychars.IndexOf(e.KeyChar) < 0) { e.Handled = true; return; } // Youre code..... base.OnKeyPress (e); } All the best, Martin

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups