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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Text Box Which Allow user to Enter only 2 number Before : and 2 num after :

Text Box Which Allow user to Enter only 2 number Before : and 2 num after :

Scheduled Pinned Locked Moved ASP.NET
6 Posts 3 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.
  • M Offline
    M Offline
    Member 4659001
    wrote on last edited by
    #1

    i need a text box by which user can enter time in hour:Min Formate Ex 08:24 (Hr:Min) i mean Text Box Which Allow user to Enter only 2 number Before : and 2 num after :

    Raghvendra

    N M 2 Replies Last reply
    0
    • M Member 4659001

      i need a text box by which user can enter time in hour:Min Formate Ex 08:24 (Hr:Min) i mean Text Box Which Allow user to Enter only 2 number Before : and 2 num after :

      Raghvendra

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Use regular expression to find value is in expected pattern. If you use this kind of textbox in many forms, I suggest making it as a custom control with all validation logic embedded. You can reuse it by dragging and dropping from toolbox.

      All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

      M 1 Reply Last reply
      0
      • N N a v a n e e t h

        Use regular expression to find value is in expected pattern. If you use this kind of textbox in many forms, I suggest making it as a custom control with all validation logic embedded. You can reuse it by dragging and dropping from toolbox.

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

        M Offline
        M Offline
        Member 4659001
        wrote on last edited by
        #3

        Sir i need A test Box Which shows fromate Like( : ) So user can enter only 2 num Before : and 2 After : , so sir how i will make hole custom textbox , i mean could u plz give me some related code for it

        Raghvendra

        N 1 Reply Last reply
        0
        • M Member 4659001

          Sir i need A test Box Which shows fromate Like( : ) So user can enter only 2 num Before : and 2 After : , so sir how i will make hole custom textbox , i mean could u plz give me some related code for it

          Raghvendra

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Member 4659001 wrote:

          So user can enter only 2 num Before : and 2 After : ,

          You can hook JS keypress events of the texbox and check for the pattern. Regular expressions can be used here to check user has entered in the expected format. Here is a good RegEx tutorial, http://www.regular-expressions.info/[^]. Consider getting a good book on ASP.NET and Java Script.

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

          M 1 Reply Last reply
          0
          • N N a v a n e e t h

            Member 4659001 wrote:

            So user can enter only 2 num Before : and 2 After : ,

            You can hook JS keypress events of the texbox and check for the pattern. Regular expressions can be used here to check user has entered in the expected format. Here is a good RegEx tutorial, http://www.regular-expressions.info/[^]. Consider getting a good book on ASP.NET and Java Script.

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

            M Offline
            M Offline
            Member 4659001
            wrote on last edited by
            #5

            Sir this time i m very specific, i need to create control , The control provides the dots between the numbers automatically. An example is the IP address control in many Windows networking dialogs, which is a combination of four three-character fields that accept only numbers. i need same

            Raghvendra

            1 Reply Last reply
            0
            • M Member 4659001

              i need a text box by which user can enter time in hour:Min Formate Ex 08:24 (Hr:Min) i mean Text Box Which Allow user to Enter only 2 number Before : and 2 num after :

              Raghvendra

              M Offline
              M Offline
              meghamaharshi
              wrote on last edited by
              #6

              Here is javascript function may help u to solve ur problem... var cnt=0; function Format(e) { if(e.keyCode <= 57 && e.keyCode >= 48 ) { var str=new String(); str=document.getElementById("txt").value; if(str.length<=4) { cnt=cnt+1; if(cnt==2 || str.length==2) { var str=document.getElementById("txt").value; str=str+":"; document.getElementById("txt").value=str; } if(document.getElementById("txt").value=='') cnt=0; if(cnt>3 && str.length>4) e.keyCode=0; } else e.keyCode=0; } else e.keyCode=0; }

              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