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. Regular Expression validator problem

Regular Expression validator problem

Scheduled Pinned Locked Moved ASP.NET
helpquestionregex
4 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.
  • J Offline
    J Offline
    Jmshastri
    wrote on last edited by
    #1

    Hi all. How can i validate a date in format of DD/MM/YYYY using regularexpressionvalidator control? please help me out.

    G M H 3 Replies Last reply
    0
    • J Jmshastri

      Hi all. How can i validate a date in format of DD/MM/YYYY using regularexpressionvalidator control? please help me out.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Use this pattern: "\d{2}/\d{2}/\d{4}". This will of course only verify that the format is correct, it can't verify that the date actually exists. You can make the verification a bit better by making sure that the date is in the range 1 to 31 and so on, but still that won't see that a date like 31/02/2006 does not exist. --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • J Jmshastri

        Hi all. How can i validate a date in format of DD/MM/YYYY using regularexpressionvalidator control? please help me out.

        M Offline
        M Offline
        minhpc_bk
        wrote on last edited by
        #3

        You can use the CompareValidator with the DataTypeCheck operator and Type="Date" to validate if the textbox value is a valid date. You also should remember that the date format used by the validator is specified based on the current culture value when the validator control renders, for example if the current culture is set for the "en-GB" value, then the dateorder will be mdy, and the validator will accept the values like 18/4/2006 or 18/04/2006 ..., the delimiter can be either - or /. If you want to use the fixed format like you said, you can either implement a custom validator for this or use an additional RegularExpressionValidator with the pattern suggested by Guffa. For more information on how to set the culture value, you can see MSDN[^]

        1 Reply Last reply
        0
        • J Jmshastri

          Hi all. How can i validate a date in format of DD/MM/YYYY using regularexpressionvalidator control? please help me out.

          H Offline
          H Offline
          HimaBindu Vejella
          wrote on last edited by
          #4

          Use Compare Validator that would be correct solution in this scenario "Aim to go where U have never been B4 and Strive to achieve it" http://groups.yahoo.com/subscribe/dotnetforfreshers http://himabinduvejella.blogspot.com

          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