C# Regular Expression to validate a date?

后端 未结 10 1796
后悔当初
后悔当初 2020-12-30 04:45

I am trying to validate a date entered into a text box. There is an input mask on the textbox which forces input of xx/xx/xxxx. I am trying to use a regular expression valid

10条回答
  •  一向
    一向 (楼主)
    2020-12-30 05:33

    Why not use one of the methods available in the System.DateTime namespace? You could use DateTime.TryParse() (edit: DateTime.TryParseExact() is probably the right suggestion) to accomplish the validation.

提交回复
热议问题