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. Web Development
  3. ASP.NET
  4. Regular expression for valid time format (hr:min:sec) entered by user in text box

Regular expression for valid time format (hr:min:sec) entered by user in text box

Scheduled Pinned Locked Moved ASP.NET
cssregextutorial
5 Posts 2 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.
  • F Offline
    F Offline
    For_IT
    wrote on last edited by
    #1

    Hi all I have a text box, which will take input from user in hr:min:sec format. I would like to verify: 1. User enters the in correct format, 2. I would like to verify of the values are correct, e.g. for hrs < 24, for mins it should be less than 60 and simillarly for sec should be less than 60. or is there any way, that I can set the text box to take user input as hrs:min:sec format. pls guide me. thanks

    P 1 Reply Last reply
    0
    • F For_IT

      Hi all I have a text box, which will take input from user in hr:min:sec format. I would like to verify: 1. User enters the in correct format, 2. I would like to verify of the values are correct, e.g. for hrs < 24, for mins it should be less than 60 and simillarly for sec should be less than 60. or is there any way, that I can set the text box to take user input as hrs:min:sec format. pls guide me. thanks

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Have you looked at the validation controls that are available?

      "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

      F 1 Reply Last reply
      0
      • P Paul Conrad

        Have you looked at the validation controls that are available?

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

        F Offline
        F Offline
        For_IT
        wrote on last edited by
        #3

        Thanks for reply. I have regular expression validator, but wanted to have the regular expression to check user input in HH:MM:SS format. I am using, regular expression ^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$

        P 1 Reply Last reply
        0
        • F For_IT

          Thanks for reply. I have regular expression validator, but wanted to have the regular expression to check user input in HH:MM:SS format. I am using, regular expression ^([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          Have you looked at Expresso, here at CP? It is a really great tool for building/testing regular expressions.

          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

          F 1 Reply Last reply
          0
          • P Paul Conrad

            Have you looked at Expresso, here at CP? It is a really great tool for building/testing regular expressions.

            "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

            F Offline
            F Offline
            For_IT
            wrote on last edited by
            #5

            Thanks for the information. I have following regular expression to check HH:MM:SS format of the text box.

            ^([0-1]?[0-9]|2[0-3]):([0-5]?[0-9]):([0-5]?[0-9])$

            I would like to give the flexibility to the user to enter the data in MM:SS format too. I was trying to modify the above regular expression to validate for the MM:SS format too. but didnt get the success. can anyone please help me to build the regular expression to allow user to enter data in HH:MM:SS and MM:SS format too. Thanks a lot.

            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